This tutorial will help you to:
This API will not do the following:
site-admin group and therefore revoke org-admin role from a user.To complete this tutorial, you need the following:
API token ≠ API key:
This is a required path parameter to delete a group.
An API token is needed to get the groupId in the next step. Use the API token to authenticate your script.

To create an API token:
To get the groupId:
Use the Jira group search API with the API token and Basic authentication to get the groupId: GET /rest/api/3/groups/picker
1 2curl --request GET \ --url 'https://your-domain.atlassian.net/rest/api/3/groups/picker' \ --user 'email@example.com:<api_token>' \ --header 'Accept: application/json'
Search the results by email address or name to find the correct accountId.
Learn more about the Jira API.
If you don’t have Jira, export a .csv of the user list. Make sure to select pivot to column when prompted. Learn how to export users from a site
The Delete group script uses an API key as a Bearer access token. It also uses the Organization ID field as a path parameter.

To create an API key and get the Organization ID:
Learn more about the API keys.
The v2 APIs are directory-aware, so you need a directoryId as a path parameter. Use the API key and Organization ID from the previous step with the Get directories endpoint to get the directoryId: GET /admin/v2/orgs/{orgId}/directories
1 2curl --request GET \ --url 'https://api.atlassian.com/admin/v2/orgs/{orgId}/directories' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
Search the results to find the correct directoryId.
Learn more about the Get directories API.
Use the groupId, directoryId, API key and Organization ID from the previous steps to delete group: DELETE /v2/orgs/{orgId}/directories/{directoryId}/groups/{groupId}
1 2curl --request DELETE \ --url 'https://api.atlassian.com/admin/v2/orgs/{orgId}/directories/{directoryId}/groups/{groupId}' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
To force delete even when the group is not empty:Use the groupId, directoryId, API key and Organization ID from the previous steps to delete group: DELETE /v2/orgs/{orgId}/directories/{directoryId}/groups/{groupId}?forceIfNotEmpty=true
1 2curl --request DELETE \ --url 'https://api.atlassian.com/admin/v2/orgs/{orgId}/directories/{directoryId}/groups/{groupId}?forceIfNotEmpty=true' \ --header 'Authorization: Bearer <access_token>' \ --header 'Accept: application/json'
Make your first request and get started with the Delete group API and get more information on error codes.
Rate this page: