0

Get long-running task

by
Published Oct 17, 2025

Returns information about an active long-running task (e.g. space export), such as how long it has been running and the percentage of the task that has completed. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site ('Can use' global permission).

Script confluence Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Confluence = {
3
	email: string
4
	apiToken: string
5
	domain: string
6
}
7
/**
8
 * Get long-running task
9
 * Returns information about an active long-running task (e.g. space export),
10
such as how long it has been running and the percentage of the task that
11
has completed.
12

13
**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:
14
Permission to access the Confluence site ('Can use' global permission).
15
 */
16
export async function main(auth: Confluence, id: string) {
17
	const url = new URL(`https://${auth.domain}/wiki/rest/api/longtask/${id}`)
18

19
	const response = await fetch(url, {
20
		method: 'GET',
21
		headers: {
22
			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
23
		},
24
		body: undefined
25
	})
26
	if (!response.ok) {
27
		const text = await response.text()
28
		throw new Error(`${response.status} ${text}`)
29
	}
30
	return await response.json()
31
}
32