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

# Authentication

## Obtain token

### Request

<mark style="color:blue;">`POST`</mark> `[base]/token/`

<table><thead><tr><th width="135">Name</th><th width="106">Type</th><th width="100">Required</th><th>Description</th></tr></thead><tbody><tr><td><code>client_id</code></td><td>string</td><td>Yes</td><td>Your API key.</td></tr><tr><td><code>client_secret</code></td><td>string</td><td>Yes</td><td>Your API secret.</td></tr></tbody></table>

#### Request example

{% tabs %}
{% tab title="cURL" %}

```sh
curl --location '{base_url}/token/' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
  "data": {
    "type": "auth-token",
    "attributes": {
      "client_id": "<Your API key>",
      "client_secret": "<Your API secret>"
    }
  }
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = '[base]/token/'

headers = {
  'content-type': 'application/vnd.api+json',
}

data = {
  'data': {
    'type': 'auth-token',
    'attributes': {
      'client_id': '<Your API key>',
      'client_secret': '<Your API secret>',
    }
  }
}

requests.post(url, headers=headers, json=data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new GuzzleHttp\Client();
try {
  $res = $client->post('[base]/token/', [
    'json' => [
      'data' => [
        'type' => 'auth-token',
        'attributes' => [
          'client_id' => '<Your API key>',
          'client_secret' => '<Your API secret>',
        ],
      ],
    ],
    'headers' => [
      'Content-Type' => 'application/vnd.api+json',
    ],
  ]);
echo $res->getBody();
} catch (RequestException $e) {}
```

{% endtab %}
{% endtabs %}

### Response

<table><thead><tr><th width="231">Name</th><th width="106">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>access</code></td><td>string</td><td>Your access token. It has an expiry time and after expiration should be refreshed by resending the request.</td></tr><tr><td><code>expires_in</code></td><td>number</td><td>The lifetime of the token, in seconds.</td></tr><tr><td><code>token_type</code></td><td>string</td><td>Always `"Bearer"`.</td></tr></tbody></table>

#### Response example

{% code overflow="wrap" %}

```json
{
  "data": {
    "type": "auth-token",
    "id": "0",
    "attributes": {
      "access": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjMy...",
      "expires_in": 3599,
      "token_type": "Bearer"
    }
  }
}
```

{% endcode %}

#### Response codes

<table><thead><tr><th width="134">HTTP code</th><th width="170">Description</th><th>Suggested action</th><th></th></tr></thead><tbody><tr><td><mark style="color:green;"><code>200</code></mark></td><td>OK</td><td>—</td><td></td></tr><tr><td><mark style="color:red;"><code>400</code></mark></td><td>No active account found with the given credentials</td><td>Resend the request with the correct credentials.</td><td></td></tr><tr><td><mark style="color:red;"><code>429</code></mark></td><td>Too many requests</td><td>Try again later.</td><td></td></tr><tr><td><mark style="color:red;"><code>4xx</code></mark></td><td>Incorrect request</td><td>Resend the request with the correct parameters.</td><td></td></tr><tr><td><mark style="color:red;"><code>5хх</code></mark></td><td>—</td><td>Server error</td><td>Try again later.</td></tr></tbody></table>


---

# 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.b2binpay.com/api-guide/authentication.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.
