tokens

Creates a first-party API token. Omit user_id (or set it to the caller's ID) to create a token for yourself. Set user_id to a service user's ID to mint a token that authenticates as that service user. Creating a token for another human user is not allowed.

The signed_token value in the response is the secret credential and is only returned once at creation time.

post/tokens

Request

  • Base URL
    https://api.opal.dev/v1
  • Auth
    HTTP bearer

Request body

token_labelstring required

A human-readable label for the token.

access_level'READ_ONLY' | 'FULL_ACCESS' required

The access level of an API token.

user_idstring uuid

The ID of the user the token should authenticate as. Omit or set to the caller's ID to create a personal token. Set to a service user's ID to mint a token for that service user.

expires_atstring date-time

Optional expiration time for the token.

Example request

{
  "token_label": "My API Token",
  "user_id": "d4a7d928-783e-4599-8ec6-088d635a5bcc",
  "expires_at": "2023-01-23T04:56:07Z"
}

Response

The created API token. signed_token is only returned on creation.

signed_tokenstring required

The secret token string. Store this securely; it is only returned once at creation time.

Example response

{
  "token": {
    "token_id": "f454d283-ca87-4a8a-bdbb-df212eca5353",
    "created_at": "2022-01-23T04:56:07Z",
    "token_preview": "ab123",
    "token_label": "My API Token",
    "creator_user_id": "d4a7d928-783e-4599-8ec6-088d635a5bcc",
    "user_id": "d4a7d928-783e-4599-8ec6-088d635a5bcc",
    "access_level": "READ_ONLY"
  },
  "signed_token": "opal_pat_abc123..."
}

Changes