# Create Access Token

In order to access the API’s, first create an access token that will be used in the header of subsequent calls for authentication.

Access tokens expire in 24 hours from the time it was created but you are able to use this method to obtain a new token.

<figure><img src="https://content.gitbook.com/content/fCUCEi1845pQGMcbjae6/blobs/2NWZ4OLvqT1z3sJFxhjA/Authentication%20Flow.png" alt=""><figcaption></figcaption></figure>

## Create Access Token

<mark style="color:green;">`POST`</mark> `/token?expires_in=1`

Access tokens are only valid for **24 hours** from its creation. Use this method if the current token is expiring soon or it may have been compromised to obtain a new Access Token. Client ID and secret credentials are provided by Optty.

#### Headers

| Name                                           | Type | Description                       |
| ---------------------------------------------- | ---- | --------------------------------- |
| content-type<mark style="color:red;">\*</mark> |      | application/x-www-form-urlencoded |

#### Request Body

| Name                                             | Type   | Description                                                            |
| ------------------------------------------------ | ------ | ---------------------------------------------------------------------- |
| client\_id<mark style="color:red;">\*</mark>     | string | Client\_ID credentials provided by Optty                               |
| client\_secret<mark style="color:red;">\*</mark> | string | Client secret credentials provided by Optty                            |
| grant\_type<mark style="color:red;">\*</mark>    | string | Always “client\_credentials”                                           |
| scope<mark style="color:red;">\*</mark>          | string | The “api-user”, this is needed to make API calls for placing an order. |

{% tabs %}
{% tab title="200: OK Success" %}

```json
Content-type application/json:

{
    "access_token": "<access token in JWT format>",
    "expires_in": 86400,
    "token_type": "Bearer",
    "scope": "api-user"
}

```

{% endtab %}
{% endtabs %}
