Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

authenticating into GraphQL API via CLI

I'm rather enjoying exploring the GraphQL capabilities in the browser-based explorer that each subdomain has.  For me, its

I'd like to take that to the next level and incorporate it into some Bash shell scripts.  However, I'm unable to figure out how to properly auth from curl.

The docs at suggest there are (2) options for authenticating via CLI: OAUTH and API TOKEN.  No further explanation or examples regarding expected headers are given for either scenario.  Searches on OAUTH lead to and the development of an app using Node.js and Docker as described in, which is way beyond the scope of a simple curl.

That leaves the API TOKEN scenario.  What I'm able to do in the browser explorer though, I'm unable to do via curl:

$ curl -s -X POST \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header "Authorization: Basic $MY_API_TOKEN" \
-d "{ query cloudid { \
tenantContexts(hostNames:['']) { \
cloudId \
} \
} \
}" \
"" | jq '.'

"code": 401,
"message": "Unauthorized"

 This post suggests using, contrary to the documentation, but that doesn't work either.

1 answer

1 accepted

0 votes
Answer accepted

I finally found  and was able to properly auth using the output of this in place of $MY_API_TOKEN:

echo -n <MY_EMAIL>:<MY_API_TOKEN> | base64

Suggest an answer

Log in or Sign up to answer
Site Admin

Atlassian Community Events