> For the complete documentation index, see [llms.txt](https://deskpro.gitbook.io/dev-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://deskpro.gitbook.io/dev-guide/api-basics/auth/api-tokens/token-exchange-endpoint.md).

# Token Exchange Endpoint

A simple way to get an API token is to use the `api_tokens` endpoint. This endpoint accepts an email address and password, and returns you an API token that you can use from that point forward.

This is an *open* API (so it doesn't require an API key to use). The purpose for this was originally to allow developers to use a custom login form. This is not very secure because *your* script needs to accept the user password and pass it on to the API -- so there's more surface area for things to go wrong and have a password leaked.

Additionally, this method does not work with any external auth providers you might set up in Deskpro (e.g. SAML, Google Apps, etc).

Here's an example

```bash
curl -X POST -H "Content-Type: application/json" \
    -d '{"email": "john@example.com", "password": "foobar"}' \
    http://example.com/api/v2/me
```

```javascript
{
    "person_id": 5,
    "token": "X:XXX",
    ...
}
```

To use a token, use the `Authorization` header like you would with an API key except instead of the string "key" use the string "token":

```bash
curl -H "Authorization: token X:XXX" \
    http://example.com/api/v2/me
```


---

# 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://deskpro.gitbook.io/dev-guide/api-basics/auth/api-tokens/token-exchange-endpoint.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.
