Follow these steps to obtain a token key and exchange it for an access token.
Step 1: Create an API Token
- In the CredoAI web app, generate a token key:
- Navigate: Your Name → Settings → Tokens.
- Add a new Token and give it a unique name.
- Save the generated token key locally.
Step 2: Exchange API Token for Access Token
- Use the token key to obtain an access token. Run the following in terminal:
curl -X "POST" "https://api.credo.ai/auth/exchange"
-H 'Content-Type: application/json; charset=utf-8'
-d '{
"api_token": "${API_TOKEN}",
"tenant": "${TENANT}"
}'
- Self-hosted customers: replace https://api.credo.ai with your Credo AI URL
- Note: be sure to replace
${API_TOKEN}
and${TENANT}
with actual values
A successful response looks like:
{
"access_token": "xaus6cMJgLq7BxCrstPothiRUiHTr5lbfc4bCTX1oUmCwjv"
}
- The access token expires after 24 hours.
Step 3: Use the Access Token in Requests
- Add the Authorization: Bearer ${ACCESS_TOKEN} header for API requests.
Example: Fetching Use Cases
curl "https://api.credo.ai/api/v2/${TENANT}/use_cases" \
-H 'Authorization: Bearer ${ACCESS_TOKEN}'
- Note: be sure to replace
${ACCESS_TOKEN}
&${TENANT}