> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/developers/gitbook-api/authentication.md). Agents can also search and read this documentation through its [MCP server](https://gitbook.com/docs/~gitbook/mcp).

# Authentication

Authenticate your requests with your user account when using the GitBook API

The GitBook API uses personal access tokens to authenticate requests.

You can view and manage your access tokens in the [Developer settings](https://app.gitbook.com/account/developer) of your GitBook user account.

API requests are authenticated using the [Bearer Auth scheme](https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes). To authenticate a request, provide the token in the `Authorization` header of the request:

```bash
curl -H "Authorization: Bearer <your_access_token>" https://api.gitbook.com/v1/user
```

Access tokens are tied to the GitBook user account for which they were created. A token can never do more than that account can.

{% hint style="warning" %}
Please be sure to keep your API access tokens secure! Do not share them in emails, chat messages, client-side code or publicly accessible sites.

If you have accidentally shared an API access token publicly, you can revoke it in the [Developer settings](https://app.gitbook.com/account/developer) of your GitBook user account by deleting it. Open the token’s **⋯** menu and choose **Delete**.
{% endhint %}

## Token access

When you create a token, you choose its access:

* **Read only**: the token can only read. The API refuses any request that would change something. Use this for dashboards, reporting scripts, and anything that doesn’t need to change content.
* **Read & write**: the token can read and change everything your account can access. This is the default, and tokens created before access levels existed have this access.

Choose read only unless the integration needs to write. If a read-only token is exposed, it can’t change your content.

## Restrict a token by IP address

You can allow or deny specific IP ranges for a token. Use this to limit a token to your CI runners or office network.

To add a rule when you create a token, click **Add rule**, choose **Allow** or **Deny**, and enter an IP address or CIDR range. With no rules, the token works from any IP address.

You can’t change a token’s access or IP rules after you create it. To change them, delete the token and create a new one. To see a token’s rules, open its **⋯** menu and choose **Details** in [Developer settings](https://app.gitbook.com/account/developer).


---

# 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://gitbook.com/docs/developers/gitbook-api/authentication.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.
