---
title: "Request access token"
method: POST
path: "/{countryCode}/2.0/oauth/access_token"
tags: ["OAuth API"]
---

# Request access token

`POST /{countryCode}/2.0/oauth/access_token`

Returns a new OAuth Bearer access token. 

### Prerequisites

To make requests to this endpoint, you need to have the Client ID and Client Secret credentials. For more information, see [Authentication](#section/Introduction/Authentication). 

### Implementation flow

Your implementation must adhere to this flow:
1. Generate an access token.
2. Store the token, along with the expiration timestamp, in a persistent storage.
3. Attach the token as a Bearer token with every API request to a Ninja Van API. This means that for the `Authorization` HTTP header, the value must be `Bearer <INSERT ACCESS TOKEN>`.
4. Five minutes before the token expires, or if a request to a Ninja Van API returns an HTTP `401` status code, generate a new token.

Validity period is dynamic and may change from time to time. The minimum validity period is *one hour*.

**Note:** Always set `grant_type` to `client_credentials`.

## Path parameters

- `countryCode` 'SG' | 'MY' | 'TH' | 'ID' | 'VN' | 'PH' | 'MM', required

## Request body

- AccessTokenGrantRequest
  - `client_id` string, required — Client ID from your Ninja Dashboard account.
  - `client_secret` string, required — Client Key from your Ninja Dashboard account.
  - `grant_type` 'client_credentials', required

## Response `200`

Access token was successfully generated.

- AccessTokenGrantResponse
  - `access_token` string, required — Bearer token to be included in the `Authorization` HTTP header for all API requests.
  - `expires` integer, required — The epoch timestamp at which the access token expires.
  - `expires_in` integer, required — The number of seconds at which the access token expires.
  - `token_type` 'bearer', required

## Other responses

- `400` — Access token wasn't generated because of an issue with the request.
- `500` — Access token wasn't generated because of an issue with the server.

---

[API](https://skmtc.net/ninjavan/apis/ninja-van-api.md) · [All operations](https://skmtc.net/ninjavan/apis/ninja-van-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/ninjavan/ninja-van-api/revisions/9096adaf76a2/schema)
