Getting "Unauthorized" when suspending users with organization API

Hello,

I have been trying to implement a feature where we can suspend our organization users with the help of an API but i can’t get past this error im facing. Im complying (i think) everything in the documentation and consulted several AI tools but not been able to get a reasonable conclusion on why I am getting this error:

Documentation im applying:

Retrieving the users account_id by this > Suspend user access

Suspending the user by this > Suspend user access (same page of the first just downwards)

I am using the following variables as a input for the commands:

ORG_API_KEY="org api key"
ORG_ID="id generated when generating my organization api"
JIRA_API_TOKEN="redacted"
JIRA_ADMIN_EMAIL="myadminemail@invent.ai"
JIRA_URL="https://mydomain.atlassian.net"
ACCOUNT_ID="account id of the user i want to suspend"

The suspend command:

curl --request POST   --url "https://api.atlassian.com/admin/v1/orgs/$ORG_ID/users/$ACCOUNT_ID/suspend-access"   --user "$ADMIN_EMAIL:$ORG_API_KEY"   --header "Accept: application/json"   --header "Content-Type: application/json"

Result:
{"code":401,"message":"Unauthorized"}

I can confirm the organization id & account id from above variables are correct because when i manually open the admin portal and navigate to the user from Directory > Users, both ids appears in the url link.

My account is already an admin and i have no trouble accessing the organization admin panel (Was able to create the org api key hence).

What am i missing here? I also increased the verbosity via curl -v and noticed this additionally:

x-failure-category: FAILURE_CLIENT_AUTH_MISMATCH

I think relates to authentication bearer with a basic whereas it requests OAuth 2.0 token but i havent seen anything related to this in the documentation so im not entirely sure.

Would appreciate any insights i can get, thank you.

As described in the Authentication section of the Organizations API documentation, those APIs (and all the other Cloud Admin APIs) use neither Basic Auth nor OAuth 2.0, but with the Org Admin’s API Key supplied directly as a Bearer token, without any encoding, into the Authorization request header.

You can validate that auth method with any API test tool such as Postman:

then looking at the request session log / console log:

If you search the public Atlassian Community forum, you will find the topic of how to access and use the Cloud Admin APIs has been discussed extensively.

Good luck.

I have totally forgot using postman to easily debug this, it is not often than that i develop a feature that sends API requests. With further checking the documentation & postman i was able to send a valid request.

Thank you!