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

Tokens API

Create and manage API Access Tokens.

An API Access Token grants access to specific data through a specific connection. Because the token travels to the browser in a public application, its grants are the security boundary — scope them to exactly what the application reads and nothing more.

Tokens created here are identical to the ones created in the Workspace, so you can manage them either way.

Endpoint
What it does

POST /v3/tokens

Create a token

GET /v3/tokens

List tokens

GET /v3/tokens/{token}

Get a token

PATCH /v3/tokens/{token}

Update a token

DELETE /v3/tokens/{token}

Delete a token

These endpoints need an OAuth Access Token, not an API Access Token. See Authorization.

How grants work

Each grant pairs a connection with a source:

{
  "grants": [
    { "connection_name": "carto_dw", "source": "carto-demo-data.demo_tables.airports" }
  ],
  "allowed_apis": ["sql", "maps"]
}
  • source is a fully qualified table name or a SQL query. resource accepts wildcards such as project.dataset.*.

  • * grants everything reachable through the connection — avoid it in public applications.

  • allowed_apis limits which APIs accept the token.

  • referers limits which domains can use it.

A token without expiration_date never expires, and the expiration can only be set at creation. To rotate, create a new token and delete the old one.

Endpoints

Create a token

post
/v3/tokens

Creates an API Access Token.

Each grant ties a connection to a source — a fully qualified table name, a SQL query, or * for everything reachable through that connection. Keep grants as narrow as your application allows.

Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Body
referersstring[]Optional

Restrict use of the token to these HTTP referers. Empty means any.

namestringOptional

A name for the token. Generated if omitted.

expiration_datestring · date-timeOptional

When the token stops working. Must be in the future. Omit for a token that never expires. Can only be set at creation.

Responses
201

The token was created.

application/json
tokenstringOptional

The token to send in the Authorization header.

referersstring[] · nullableOptional
namestringOptional
user_idstring · nullableOptional
account_idstringOptional
created_atstring · date-timeOptional
updated_atstring · date-timeOptional
expiration_datestring · nullableOptional
post/v3/tokens

List tokens

get
/v3/tokens

Lists the API Access Tokens you can see.

Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Responses
200

The tokens.

application/json
tokenstringOptional

The token to send in the Authorization header.

referersstring[] · nullableOptional
namestringOptional
user_idstring · nullableOptional
account_idstringOptional
created_atstring · date-timeOptional
updated_atstring · date-timeOptional
expiration_datestring · nullableOptional
get/v3/tokens

Get a token

get
/v3/tokens/{token}
Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Path parameters
tokenstringRequired

The token string.

Responses
200

The token.

application/json
tokenstringOptional

The token to send in the Authorization header.

referersstring[] · nullableOptional
namestringOptional
user_idstring · nullableOptional
account_idstringOptional
created_atstring · date-timeOptional
updated_atstring · date-timeOptional
expiration_datestring · nullableOptional
get/v3/tokens/{token}

Update a token

patch
/v3/tokens/{token}

Replaces the grants, referers, allowed APIs and name of a token. The expiration date can't be changed — create a new token instead.

Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Path parameters
tokenstringRequired

The token string.

Body
referersstring[]Optional

Restrict use of the token to these HTTP referers. Empty means any.

namestringOptional

A name for the token. Generated if omitted.

expiration_datestring · date-timeOptional

When the token stops working. Must be in the future. Omit for a token that never expires. Can only be set at creation.

Responses
200

The updated token.

application/json
tokenstringOptional

The token to send in the Authorization header.

referersstring[] · nullableOptional
namestringOptional
user_idstring · nullableOptional
account_idstringOptional
created_atstring · date-timeOptional
updated_atstring · date-timeOptional
expiration_datestring · nullableOptional
patch/v3/tokens/{token}

Delete a token

delete
/v3/tokens/{token}

Deletes a token and returns the deleted object.

Authorizations
AuthorizationstringRequired

An API Access Token or an OAuth Access Token, sent as Authorization: Bearer <token>.

Path parameters
tokenstringRequired

The token string.

Responses
200

The deleted token.

application/json
tokenstringOptional

The token to send in the Authorization header.

referersstring[] · nullableOptional
namestringOptional
user_idstring · nullableOptional
account_idstringOptional
created_atstring · date-timeOptional
updated_atstring · date-timeOptional
expiration_datestring · nullableOptional
delete/v3/tokens/{token}

Last updated

Was this helpful?