> For the complete documentation index, see [llms.txt](https://apidocs.paygateway.paytota.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.paygateway.paytota.com/authorization/access-token.md).

# Access Token

All request must have an **Access token**. Access tokens are used to make API requests on behalf of your merchant account. It is used for **Authorization**.

Access tokens must be kept confidential in transit and in storage. The only parties that should ever see the access token are Paytota Paygateway APIs and your servers. Your application should ensure the storage of the access token is not accessible to other applications

## How to get an access token

You have to use your merchant [**api\_key**](/dashboard/api-tokens.md#api_key) and [**api\_secret**](/dashboard/api-tokens.md#api_secret) in order to get an access token by making a request as below

#### Live

```typescript
POST  https://paygateway.paytota.com/v1/auth/token
```

**Sandbox**

```
POST  https://sandbox.paygateway.paytota.com/v1/auth/token
```

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

#### Request Headers

| Header           | Value                  | Required |
| ---------------- | ---------------------- | -------- |
| **Content-Type** | **`application/json`** | YES      |
| **Accept**       | **`application/json`** | YES      |
| **Secret-Key**   | **`YOUR_SECRET`**      | YES      |
|                  |                        |          |

#### Request Body

| Parameter       | Type    | Description                                       | Required                      |
| --------------- | ------- | ------------------------------------------------- | ----------------------------- |
| **api\_key**    | string  | Obtained from merchant profile account            | YES                           |
| **expires\_in** | integer | The time taken for the token to expire in seconds | Optional. Default 900 seconds |
|                 |         |                                                   |                               |

#### Response body

| Parameters | Type    | Description                                                                  |
| ---------- | ------- | ---------------------------------------------------------------------------- |
| token      | string  | The access token that can be used to make a request on any of the end points |
| expires    | integer | The timestamp of when the token will expire                                  |
|            |         |                                                                              |

```typescript
{ 
    "api_key": "2882jj2hh288282jj2", // Obtain from your merchant profile" 
    "expires_in": 300
}
```

```typescript
{
  "code": 200,
  "status": "success",
  "message": "Token generated",
  "data": {
    "token": "JWT eyJ0eXAiOiBBV1QzI1NiJ9.eTAW0InJvbGUi2YifQ.f6FPyTxzchGD7ed55Rw7ruqe6P_Go",
    "expires": 1622197906
  }
}
```

{% hint style="danger" %}

#### Header: Authorization

All Requests to whatever Paytota Paygateway end point must contain an authorization header that contains the token generated. This provides another layer of security. To even strengthen the security further, this token should be as short lived as much as possible based on the specified scenario.

**`e.g`"Authorization: JWT eyJ0ejjsjjdjjjjsjjs.eTThhhshhshhhs.88asd998sads..."**
{% endhint %}
{% endtab %}
{% endtabs %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://apidocs.paygateway.paytota.com/authorization/access-token.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
