I have come across multiple posts around the net about trying to get all the JSM Customers via Atlassians API.
Some Customers do not have an associated Organisation.
I can use the JSM API to get Customers who are associated with an organisation https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-organization/#api-rest-servicedeskapi-organization-organizationid-user-get
There is no JSM API to just get all Customers, regardless of organisation.
The Jira Users/User Search APIs suggests that you might be able to get Customers as the account type “customer” is listed as a possible response, however when called as a privileged user or asApp with supposedly required permissions of read:jira-user as documented here https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-users-search-get I only get “app” and “atlassian” account types.
So it seems impossible to get ALL JSM Customers.
Is there a proper way to do this that I’m missing, or is Atlassian planning to support this needed functionality?
if you explicitly get a customer via the account ID it returns the customer:
const response = await requestJira(`/rest/api/3/user?accountId=qm:xxxxxxxxx-840f-48f0-97ed-bf9ffccbaf4f:066610b3-62e6-429a-a145-ed43eec70615`, {
headers: {
'Accept': 'application/json'
}
}
);
const json = await response.json();
console.log('[contact:importjsm] getCustomers response', response.status, json);
displayName: "Peter Loud", active: true, timeZone: "Australia/Sydney", locale: "en_US", groups: {…}, … }
​
accountId: "qm:xxxxxxxxx-840f-48f0-97ed-bf9ffccbaf4f:066610b3-62e6-429a-a145-ed43eec70615"
​
accountType: "customer"
​
active: true
OK this query gets the 3 active customers, and may be the answer:
const response = await requestJira(`/rest/api/3/users?maxResults=1000`, {
headers: {
'Accept': 'application/json'
}
}
);
const json = await response.json();
console.log('[contact:importjsm] getCustomers response', response.status, json.filter((user: AtUser) => user.accountType === 'customer'));
OK I’ve confirmed the above does return all customers, even ones without Organisations.
1 Like
Actually…. it doesn’t return the same customers as in the JSM Customers. sigh.
To be clear, it only returns accounts that are just customers, not all accounts considered to be customers.
If you want to find all customers you need to combine the results of the JSM Organisations API getting customers from all organisations, with the users API to get the customers that are not part of an organisation.
So if you have a user that is not part of an organisation and is a User but also a Customer you’ll miss them.