> For the complete documentation index, see [llms.txt](https://docs.carto.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.carto.com/carto-for-developers/reference/carto-api/tokens-api.md).

# Tokens API

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 |

{% hint style="info" %}
These endpoints need an **OAuth Access Token**, not an API Access Token. See [Authorization](/carto-for-developers/reference/carto-api.md#authorization).
{% endhint %}

## How grants work

Each grant pairs a connection with a source:

```json
{
  "grants": [
    { "connection_name": "carto_dw", "source": "carto-demo-data.demo_tables.world_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

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/tokens" method="post" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/tokens" method="get" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/tokens/{token}" method="get" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/tokens/{token}" method="patch" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}

{% openapi src="<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>" path="/v3/tokens/{token}" method="delete" %}
<https://openapi.gitbook.com/o/zP3LT2Qhlb5jPWQCfWV3/spec/carto-api>
{% endopenapi %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.carto.com/carto-for-developers/reference/carto-api/tokens-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
