Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Authentication and Permissions

To use a Tenant API, you must authenticate as a user or application with permission to perform the requested operation in your tenant. Each API guide explains which credentials and token audiences it accepts, how to identify the tenant in a request, and which permissions you need.

Choose credentials

Use a credential type that the API guide supports:

  • API Key: For an application or unattended integration, use a tenant API Key if the API guide says the API supports API Keys. See Set up API Key access.

  • Other schemes: Some operations use another scheme, such as short-lived file-transfer tokens. Follow the API guide for those operations.

Identify the tenant

Wherever <tenant-id> appears in this documentation, replace it with the tenant identifier from your Tenant Workspace URL. For example, the tenant ID in https://app.example.my.contextual.io is example, the label immediately before .my.contextual.io.

Some APIs call the tenant ID the organization ID. An operation may use the hostname, require x-org-id: <tenant-id>, or take the tenant ID in its path. The API guide says which is required. When both the hostname and a header identify the tenant, their values must agree.

Permissions for managing API Keys

You manage API Keys in the new Admin Console at https://next.<tenant-id>.my.contextual.io. In the navigation menu, under Admin, select API Keys, then select a key to open its Settings and Permissions tabs.

Your Role and the key's permissions

Two separate sets of permissions apply:

  • Your Role permissions control what you can do with keys in the Admin Console, such as create a key or copy its Client Secret. An administrator assigns Roles to people.

  • The key's permissions control what an application can do with the key's access tokens. You set them on the key's Permissions tab. See Assign permissions.

A key doesn't inherit the access of the person who creates it. A new key has no permissions until someone saves them on its Permissions tab.

Give Client grants permissions only to people you trust, because these permissions control what applications can do with each key.

Tenant API permissions

On a Role's Permissions tab, the Tenant API section controls API Key work. Each row has Read, Create, Update, and Delete actions.

Row
What it covers

Clients

The API Keys themselves: their name, description, status, and Client ID.

Client secrets

Each key's Client Secret. Read lets you reveal or copy it, and Update lets you rotate it. The secret is created with the key and removed with it, so API Key tasks don't use Create or Delete in this row.

Client grants

Each key's permissions. A grant connects a key to an API and lists what the key can do there.

Resource servers

API registrations. Each one has the API Identifier that you use as the token audience, and the permissions that the API offers. API Key tasks only read them.

Permissions for each task

Your Role needs these permissions for each API Key task. Permissions are in the Tenant API section unless the table names another section. To open a key, you also need Clients → Read.

Task
Role permissions

See the list of keys and open a key

Clients → Read

Create a key

Clients → Create

Save a new key's first permissions

Client grants → Read and Create, Resource servers → Read, and Service components → Object Types → Read

Change a key's permissions

Client grants → Read and Update, Resource servers → Read, and Service components → Object Types → Read

See the key's API Identifier

Client grants → Read, Resource servers → Read, and Service components → Object Types → Read

Reveal or copy the Client Secret

Client secrets → Read

Rotate the Client Secret

Client secrets → Update

Change the name or description, or enable or disable a key

Clients → Update

Delete a key

Clients → Delete and Client grants → Delete

The key's Permissions tab lists the tenant's Object Types. It needs Service components → Object Types → Read, even if you don't give the key access to Object Types. If the tab shows Couldn't load resource servers, Couldn't load grants, or Couldn't load Object Types, check the matching permission.

The Console can show a control even when your Role doesn't allow the action. The service checks your permissions when you use the control.

Get a Role for API Key work

If your Role lacks a permission that you need, ask an administrator to add it to your Role or to assign you another Role. An administrator can create a Role for API Key work:

  1. In the navigation menu, under Admin, select Roles, then click New role.

  2. Enter a Name and, optionally, a Description. Click Create role. The Role's Permissions tab opens.

  3. Select the permissions for the tasks that the person needs. For example, to let someone create keys, set and change their permissions, and copy their Client Secrets, select:

    • Tenant API → Clients → Read and Create

    • Tenant API → Client secrets → Read

    • Tenant API → Client grants → Read, Create, and Update

    • Tenant API → Resource servers → Read

    • Service components → Object Types → Read

  4. Click Save permissions.

  5. Under Admin, select Users. In the person's row, click Edit. Under Roles, select the Role, then click Save changes.

You can't change the permissions of a system Role that the platform manages. To give different access, create a Role.

For these steps, the administrator's Role needs these permissions:

  • Tenant security → Roles → Read, Create, and Update

  • Tenant security → Team members → Read and Update

  • Service components → Object Types → Read, because a Role's Permissions tab also lists the tenant's Object Types

Set up API Key access

Each API Key has a Client ID and Client Secret, which an application exchanges for an access token. To set up access, create a key, assign its permissions, and get a token. To create a key and assign its permissions, your Role must have the permissions for each task.

Create an API Key

  1. In the Admin Console's navigation menu, under Admin, select API Keys.

  2. Click New API key.

  3. Enter a Name that identifies the key in lists.

  4. Optionally, enter a Description of the key's purpose.

  5. Click Create API key.

The Console opens the new key's Permissions tab. The key has no permissions until you save them there. You can change the name and description later.

Assign permissions

The key's Permissions tab sets what the key's access tokens can do. These permissions belong to the key, not to your Role. Grant only the permissions that your application's operations need. Each API guide lists the permissions its operations use. The generated Native Object API reference lists the scopes that each Native Object operation needs.

The tab sets the key's permissions for the Native Object API and shows its API identifier. Set permissions in these sections:

  • Service components: Manage definitions and components, such as Object Types, AI Search Profiles, and Agents.

  • Object data & action execution: Access Records and execute Actions for Object Types. Each row offers Read, Create, Update, Delete, Execute, and Reveal. For how Reveal affects secret values in Records, see Secrets. Use the All Object Types row for all current and future Object Types in the tenant, or the row for a specific Object Type.

When a wildcard row grants an action, the tab shows the cells it covers as checked and locked.

The two sections are separate. Permission to read an Object Type's Records does not by itself grant permission to change its definition. Administration and platform operations have their own caller and permission requirements.

After you select the permissions, click Save permissions. The first save creates the key's grant, and later saves update it. Permission changes can take up to about five minutes to apply in services that cache access checks.

To inspect a token's granted permissions, see the Auth Administration API's caller requirements and example request. That API must accept the token. The result does not establish access to another API.

Get and use an access token

Your application needs three values from the key.

  • Client ID and Client Secret: On the Settings tab, under Client details, click the copy icon next to each value. The Client Secret is hidden by default; click the lock icon to reveal it in the browser.

  • API Identifier: Shown as API identifier on the Permissions tab. Use it as the token request's audience.

Keep the Client Secret in trusted server-side code, and protect access tokens.

Send a POST request to https://auth.<tenant-id>.my.contextual.io/oauth/token with the Content-Type: application/json header. Replace <tenant-id> with your tenant ID. In the following JSON body, replace yourClientId and yourClientSecret with the key's values. Replace the example audience, https://contextual/no-api, with the key's API Identifier.

A successful request returns an access token and its lifetime in seconds, as in this example response:

Send the token in the Authorization: Bearer <access-token> header. Use the returned expires_in value to request a new token before the current one expires.

The default tenant setup uses a shared API Identifier. You can reuse a token with APIs that support API Key tokens and accept that audience, with the required tenant context and permissions. Check each API guide before reusing a token.

Manage an API Key

To manage a key, select it under API Keys and open its Settings tab. Each task needs the Role permissions in Permissions for each task.

Edit details

Under General, change the Name or Description, then click Save changes. Client details shows the Client ID and Client Secret. To copy them, see Get and use an access token.

Disable or delete a key

To disable or enable the key without deleting it, set Status under General to Disabled or Enabled, then click Save changes. The API Keys list shows an enabled key's status as Active. Disabling prevents new access tokens. Some services cache access checks for existing tokens for up to five minutes. Re-enabling allows unexpired tokens to be used again.

To remove the key and its permissions permanently, under Danger zone, click Delete next to Delete API key. Type the key's Client ID to confirm, then click Delete API key. You can't undo a deletion.

Rotate the Client Secret

To replace the key's Client Secret, under Danger zone, click Rotate next to Rotate client secret. Type rotate to confirm, then click Rotate secret. Consider rotating the secret periodically. The old Client Secret stops working immediately, and you can't undo the rotation. Update applications and Client Grant Connections that use the key with the new Client Secret.

Last updated

Was this helpful?