---
page_title: Generate/Refresh token API
product: JUSPAY Unified Dashboard
page_source: https://juspay.io/in/docs/dashboard/docs/oauth-20-flow-for-dashboard-apis/generate-refresh-token-api
openapi: https://juspay.io/in/docs/api/swagger?document=https%3A%2F%2Fjuspay.io%2Fin%2Fdocs%2Fdashboard%2Fdocs%2Foauth-20-flow-for-dashboard-apis%2Fgenerate-refresh-token-api
llms_txt: https://juspay.io/in/docs/llms.txt
product_llms_txt: https://juspay.io/in/docs/dashboard/llms.txt
---

## API Version: default


# Generate/Refresh Token API



A single endpoint that issues access and refresh tokens, with behaviour set by `action`. Use `code` to exchange a merchant's authorization code for the first token pair, and `refresh_token` to obtain a new pair - no merchant action required.

action - `generate_token` exchanges the authorization code from the merchant's consent for an access token and refresh token. Call this from your backend immediately after Juspay redirects to your redirect_uri with the code.

action - `refresh_token` obtains a new access token and refresh token pair using a valid refresh token, without requiring any merchant action. Call this before the access token's expiry to keep the merchant's authorization active.## Endpoints:
- Sandbox: https://sandbox.portal.juspay.in/ec/v2/token

- Production: https://portal.juspay.in/ec/v2/token

## Request Type: 
POST

## Content-Type: 
application/json

## Headers:

#### Content-Type:
- Value: application/json
- Tags: String
## Sample Code Snippets:
### Sample Request:

#### Request Code Snippet:

```request
curl --location 'https://sandbox.portal.juspay.in/ec/v2/token' \
--header 'Content-Type: application/json' \
--data '{
    "client_id": "<client_id>",
    "client_secret": "<client_secret>",
    "action" : "generate_token",
    "code" : "<code>"
}'
```

### Snippet Header:

#### Response:
```plaintext
{
    "token_type": "Bearer",
    "expires_in": 7776000,
    "merchant_id": "newtestankit11",
    "access_token": "oauthV2_user_59c3684840840ed8bb3a37864e1b26a867b22b6c056cdf2c6f7b901340e874d3e8d235598e7d34e57c8cba981326fa",
    "refresh_token": "oauthV2_user_45b172fc52bfa0beb9796e4aad4cefd7019c0d8dad5f6ee1fb092d0155eefcb721115f74839fdd0db535d6b2615d78cbdf883fdf0b82024e715dcc0151932ab6"
}
```

## Body Parameters:
### Basic Parameters:

#### client_id:
- Description: client ID from create client response
- Value: <client_id>
- Tags: String

#### client_secret:
- Description: client secret from create client response
- Value: <client_secret>
- Tags: String

#### action:
- Description: generate_token | refresh_token
- Value: generate_token
- Tags: String

#### code:
- Description: Mandatory if action is passed as generate_tokenReceived on the redirect_uri post authorization
- Value: <code>
- Tags: String, Conditionally Required

#### refresh_token:
- Description: Mandatory if action is passed as refresh_token
- Value:  <refresh_token>
- Tags: String, Conditionally Required
## API Responses:
### 200:

#### token_type:
- Value: Bearer
- Tags: String

#### expires_in:
- Value: 7776000
- Tags: String

#### merchant_id:
- Value: newtestankit11
- Tags: String

#### access_token:
- Value: oauthV2_user_59c3684840840ed8bb3a37864e1b26a867b22b6c056cdf2c6f7b901340e874d3e8d235598e7d34e57c8cba981326fa
- Tags: String

#### refresh_token:
- Value: oauthV2_user_45b172fc52bfa0beb9796e4aad4cefd7019c0d8dad5f6ee1fb092d0155eefcb721115f74839fdd0db535d6b2615d78cbdf883fdf0b82024e715dcc0151932ab6
- Tags: String


---

## See Also

- [Partner Integration Overview](https://juspay.io/in/docs/dashboard/docs/oauth-20-flow-for-dashboard-apis/partner-integration-overview)
- [Revoke Token API](https://juspay.io/in/docs/dashboard/docs/oauth-20-flow-for-dashboard-apis/revoke-token-api)
