Authentication

To access the MyPay API, you must first authenticate your requests using an Access Token.

Required Credentials

Before starting, ensuring you obtain the following credentials from the Merchant Dashboard:

  • Client ID: Unique identifier for your application.
  • Client Secret: Secret key for the client (Keep this confidential!).
  • Base URL: The appropriate API URL for the environment you are working on.

Getting an Access Token

Use this endpoint to obtain a valid bearer token for a specific period.

Endpoint: POST /authentication/token

Headers:

Content-Type: application/json

Request Body:

{
    "client_id": "your_client_id_here",
    "secret_id": "your_client_secret_here"
}

Success Response (200 OK)

{
    "message": {
        "code": 200,
        "success": ["SUCCESS"]
    },
    "data": {
        "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
        "expire_time": 600
    },
    "type": "success"
}

[!NOTE] The access_token is valid for 10 minutes (600 seconds). You must request a new token when it expires.

Error Response (400 Bad Request)

{
    "message": {
        "code": 400,
        "error": ["Invalid client ID"]
    },
    "data": {},
    "type": "error"
}

Using the Token

After obtaining the Token, you must send it in the Authorization header with every subsequent API request:

Authorization: Bearer <your_access_token>