0

Get multiple users using ids

by
Published Oct 17, 2025

Returns user details for the ids provided in the request. Currently this API returns a maximum of 100 results. If more than 100 account ids are passed in, then the first 100 will be returned. **[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: Permission to access the Confluence site ('Can use' global permission).

Script confluence
  • Submitted by hugo697 Bun
    Created 284 days ago
    1
    //native
    2
    type Confluence = {
    3
    	email: string
    4
    	apiToken: string
    5
    	domain: string
    6
    }
    7
    /**
    8
     * Get multiple users using ids
    9
     * Returns user details for the ids provided in the request.
    10
    Currently this API returns a maximum of 100 results.
    11
    If more than 100 account ids are passed in, then the first 100 will be returned.
    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(
    17
    	auth: Confluence,
    18
    	accountId: string | undefined,
    19
    	expand: string | undefined
    20
    ) {
    21
    	const url = new URL(`https://${auth.domain}/wiki/rest/api/user/bulk`)
    22
    	for (const [k, v] of [
    23
    		['accountId', accountId],
    24
    		['expand', expand]
    25
    	]) {
    26
    		if (v !== undefined && v !== '' && k !== undefined) {
    27
    			url.searchParams.append(k, v)
    28
    		}
    29
    	}
    30
    	const response = await fetch(url, {
    31
    		method: 'GET',
    32
    		headers: {
    33
    			Authorization: 'Basic ' + btoa(`${auth.email}:${auth.apiToken}`)
    34
    		},
    35
    		body: undefined
    36
    	})
    37
    	if (!response.ok) {
    38
    		const text = await response.text()
    39
    		throw new Error(`${response.status} ${text}`)
    40
    	}
    41
    	return await response.json()
    42
    }
    43