Authorization and context identification
The AI Hub API uses a system of authorization and context identification for all API calls. Your API token authorizes the call and your user or organization ID, passed in the IB-Context
header, identifies the request as coming from your community or organization account. You can manage tokens and locate your user ID and organization ID in your user settings.
OAuth tokens
All API requests made to an AI Hub API require an OAuth access token. You can add and manage OAuth tokens yourself from the APIs settings page.
Adding tokens
You can add as many tokens as needed. While you can use a single token for all AI Hub API requests, creating multiple tokens can be helpful for organizing third-party access. For example, you might use one token per third-party application, so you can selectively manage and revoke third-party access.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Under OAuth tokens, click Add token.
-
Enter a name and description for the token. Use the description to note the token’s purpose or intended usage.
-
Select or define a custom expiration date for the token. The default setting is Never expires.
-
Click Add.
-
Copy the token.
After closing the create token dialog, the token’s value is encrypted and can’t be copied again.
Refreshing tokens
You can refresh a token as needed. Refreshing a token updates its value.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
In the OAuth tokens table, click the refresh icon
of the token to refresh. -
Select or define a custom expiration date for the token. The default setting is Never expires.
-
Click Refresh token.
-
Copy the token. After closing the refresh token dialog, the token’s value is encrypted and can’t be copied again.
Deleting tokens
If a token is no longer needed or you wish to revoke the access it grants, you can delete it.
-
In the header, click the initials icon and select Settings, then click the APIs tab.
-
In the OAuth tokens table, click the delete icon
of the token to delete. -
Enter the confirmation text and click Delete token.
IB-Context header
Because AI Hub supports having both a community account and an organization account tied to the same user ID and API token, the IB-Context
header is used in API requests to identify the context of the call. For example, commercial and enterprise organization members with accounts created before release 25.28 have two contexts: an organization account and a personal community account. The IB-Context
header specifies which context (account) to use to complete the API request.
Always define the IB-Context
header. The appropriate header value depends on the account type.
- Organization accounts — Use your organization ID. If undefined, defaults to the community context and the call might fail.
-
Community accounts — Use your user ID.
-
Service accounts — Use the organization ID or omit the header (defaults to organization ID).
Additional considerations include:
-
For requests that require consumption units to complete, the context dictates which account’s consumption units to use.
For organization members with accounts created before release 25.28, if you don’t set theIB-Context
header to the organization ID, requests use consumption units from your community account. -
The context determines where to find input files and save output files. Requests fail if specified files don’t exist in the defined context.
Finding your user ID
Your user ID is a unique, non-editable identifier tied to your account. It’s created using the email address tied to your account.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Under User ID, click the Copy icon.
Finding your organization ID
Commercial & EnterpriseAn organization ID is a unique, non-editable identifier tied to your organization.
-
In the header, click the initials icon and select Settings.
-
Select the APIs tab.
-
Under Organization ID, click the Copy icon.