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

# API Tokens

Use our API to easily control access to the parcelLab API.

## Managing Tokens

Details of how the `tokens` endpoint can be used to retrieve, create, and revoke API tokens in the parcelLab system are described below.

{% hint style="info" %}
All endpoints require a token with `generate` scope.
{% endhint %}

<details>

<summary><mark style="color:blue;">GET</mark> List of All Tokens</summary>

You can retrieve a list of all API tokens with the `tokens/list` endpoint. To use this API, you need your parcelLab `user_id` and `API token` for authentication.

The details of the Get List of All Tokens API are described in the following section.

#### API Details

<mark style="color:blue;">`GET`</mark> `https://api.parcellab.com/tokens/list`

#### Header

| Name         | Type   | Description         |
| ------------ | ------ | ------------------- |
| user         | number | parcelLab user ID   |
| token        | string | parcelLab API token |
| content-type | string | 'application/json'  |

An example request is displayed below to show the format for retrieving the list of tokens.

```bash
curl --location 'https://api.parcellab.com/tokens/list’ \
  --header 'content-type: application/json' \
  --header 'user: 100' \
  --header 'token: parcelLabAPItoken-30characters' \
```

#### Responses

* 200 - accepted

</details>

<details>

<summary><mark style="color:green;">POST</mark> Create a New Token</summary>

You can create a new API token with the `tokens/generate` endpoint. To use this API, you need your parcelLab `user_id` and `API token` for authentication. When you have generated a new API token, this can be used for authentication with the parcelLab API.

The details of the Create a New Token API are described in the following section.

#### API Details

<mark style="color:green;">`POST`</mark> `https://api.parcellab.com/tokens/generate`

#### Header

| Name         | Type   | Description         |
| ------------ | ------ | ------------------- |
| user         | number | parcelLab user ID   |
| token        | string | parcelLab API token |
| content-type | string | 'application/json'  |

#### Request Body

| Name  | Type   | Description                                            |
| ----- | ------ | ------------------------------------------------------ |
| note  | string | An associated note, which can be any string.           |
| scope | string | The scope can be one of `read`, `write` or `generate`. |

An example request is displayed below to show the format for creating a token.

```bash
curl --location 'https://api.parcellab.com/tokens/generate’ \
  --header 'content-type: application/json' \
  --header 'user: 100' \
  --header 'token: parcelLabAPItoken-30characters' \
  --data ‘{
       “note”: “track”,
       “scopes”: [
            “write”
       ]
}’
```

#### Responses

* 200 - accepted

</details>

<details>

<summary><mark style="color:green;">POST</mark> Revoke a Token</summary>

You can revoke a single API token with the `tokens/revoke` endpoint. To use this API, you need your parcelLab `user_id` and `API token` for authentication.

This action revokes the token immediately.

The details of the Revoke a Token API are described in the following section.

#### API Details

<mark style="color:green;">`POST`</mark> `https://api.parcellab.com/tokens/revoke`

#### Header

| Name         | Type   | Description         |
| ------------ | ------ | ------------------- |
| user         | number | parcelLab user ID   |
| token        | string | parcelLab API token |
| content-type | string | 'application/json'  |

#### Request Body

| Name    | Type   | Description                                  |
| ------- | ------ | -------------------------------------------- |
| tokenId | number | The token ID as specified in `/tokens/list`. |

An example request is displayed below to show the format for revoking a token.

```bash
curl --location 'https://api.parcellab.com/tokens/revoke’ \
  --header 'content-type: application/json' \
  --header 'user: 100' \
  --header 'token: parcelLabAPItoken-30characters' \
  --data ‘{
       “tokenId”: “The token ID as in /tokens/list”
}’
```

#### Responses

* 200 - accepted

</details>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.parcellab.com/docs/developers/v2/api-access/tokens.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
