> For the complete documentation index, see [llms.txt](https://6dot50.gitbook.io/6dot50-apis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://6dot50.gitbook.io/6dot50-apis/pay-api/authentication/post-authentication-gettoken.md).

# POST /authentication/getToken

### Request

Authentication is performed by performing a POST to `/authentication/getToken` with the following body:

```
{
    "key": "string",
    "secret": "string"
}
```

<table><thead><tr><th width="136">Field</th><th width="126">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>key</td><td>Yes</td><td>The key can be generated from within your PAY portal under the API tab, the credentials of which will be supplied by our team. See <a href="/6dot50-apis/pay-api/api-keys.md">API keys</a>.</td></tr><tr><td>secret</td><td>Yes</td><td>The secret can also be generated as above.</td></tr></tbody></table>

{% hint style="info" %}
The key/secret will be different between the Test and Production environments.
{% endhint %}

{% code title="Sample Request" %}

```
{
    "key": "00000000-0000-0000-0000-000000000000",
    "secret": "supersecretpassword"
}
```

{% endcode %}

### Response

If successfully authenticated, the operation will return a token. This token is to be used in subsequent requests to other operations by supplying an `Authorization` header with the value `bearer`` `*`[token]`*.

```
{
  "success": true,
  "token": "string",
  "expiresAt": "2022-09-24T13:31:00.557Z"
}
```

<table><thead><tr><th width="169.33333333333331">Field</th><th width="187">Response Type</th><th>Description</th></tr></thead><tbody><tr><td><code>success</code></td><td>boolean</td><td>Whether authentication was successful or not.</td></tr><tr><td><code>token</code></td><td>string</td><td>If success is true, this is the Bearer token to be used for subsequent calls to the API.</td></tr><tr><td><code>expiresAt</code></td><td>string($date-time)</td><td><p>If success is true, this is the date and time that the token will expire. </p><p></p><p>Tokens expire every 15 minutes and must be refreshed.</p><p> </p><p>See <a href="#token-expiry-and-refresh">Token Expiry and Refresh</a> for more information.</p></td></tr></tbody></table>

{% code title="Sample Response (Success)" %}

```
{
  "success": true,
  "token": "eyJhbGciOiJIzI1NiIsInR5cCI6IkXVCJ9.eyJpZC…",
  "expiresAt": "2022-09-24T13:31:00.557Z"
}
```

{% endcode %}

{% code title="Sample Response (Failed)" %}

```
{
  "success": false
}
```

{% endcode %}

### Token Expiry and Refresh

Tokens expire after 15 minutes. Field `expiresAt` in the response model can be used to track token expiry.&#x20;

Call the `authentication/getToken` operation again to re-authenticate and receive a new token.
