# 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="/files/nK86VdJpBfBenWbFUOPO" 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 %}


---

# Agent Instructions: 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:

```
GET https://docs.optty.com/direct-api-orders/create-access-token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
