Generate Authorization Token

This API generates an Authorization Token required to authenticate all standard checkout API requests.

The token must be obtained before initiating any checkout-related operations such as creating a payment request, checking payment status, or processing refunds. It should be included in the Authorization header for all subsequent API calls.

EnvironmentHTTP MethodAPI
SandboxPOSThttps://api-preprod.phonepe.com/apis/pg-sandbox/v1/oauth/token
ProductionPOSThttps://api.phonepe.com/apis/identity-manager/v1/oauth/token
Request Header
Header NameHeader Value
Content-Typeapplication/x-www-form-urlencoded
Request Parameters
Parameter NameParameter Value
client_idClient ID shared by PhonePe PG
client_versionClient Version shared by PhonePe PG
client_secretClient secret shared by PhonePe PG
grant_typeValue set to “client_credentials
body params
Sample Response
{
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzT24iOjE3MjA2MzUzMjE5OTYsIm1lcmNoYW50SWQiOiJWUlVBVCJ9.4YjYHI6Gy6gzOisD_628wfbaI46dMSc5T_0gZ2-SAJo",
    "encrypted_access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzT24iOjE3MjA2MzUzMjE5OTYsIm1lcmNoYW50SWQiOiJWUlVBVCJ9.4YjYHI6Gy6gzOisD_628wfbaI46dMSc5T_0gZ2-SAJo",
    "expires_in": null,
    "issued_at": 1706073005,
    "expires_at": 1706697605,
    "session_expires_at": 1706697605,
    "token_type": "O-Bearer"
}
Response Parameters
Parameter NameData TypeDescription
access_tokenStringThe token generated by PhonePe. This token is valid for a specific time, which can be determined using the expires_at field. Once expired, the token must be refreshed using the same API.
issued_atDateTimeThe timestamp in epoch (in seconds) when the token was generated
expires_atDateTimeToken expiry timestamp in epoch
token_typeStringThe type of token, which will be O-Bearer.

Access Token Guidelines!

  • You should depend on the following key response parameters:
    • access_token: This is the token that must be included in API calls with PhonePe for authentication.
    • expires_at: This indicates the token’s validity (in seconds). You must ensure that the token is refreshed before it expires. If it expires, you will have to send the request again.
  • The auth_token is required for all subsequent API calls. Use the above access token to initiate the payment process.
Is this article helpful?