Docs / Generate Token
POST /v1/auth/token

Generate Token

Generate an access token using API credentials

Generate Token

Generate a new access token using your API credentials.

Endpoint

POST /v1/auth/token

Request

Headers

Header Value
Content-Type application/json

Body Parameters

Parameter Type Required Description
api_key string Yes Your API Key
api_secret string Yes Your API Secret

Example Request

curl -X POST https://api.apimw.com/v1/auth/token \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "ak_live_abc123xyz",
    "api_secret": "sk_live_secret456"
  }'

Response

Success Response (200 OK)

{
  "success": true,
  "data": {
    "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "token_type": "Bearer",
    "expires_in": 3600,
    "refresh_token": "rt_abc123xyz456"
  }
}

Error Response (401 Unauthorized)

{
  "success": false,
  "error": {
    "code": "INVALID_CREDENTIALS",
    "message": "Invalid API Key or Secret"
  }
}

Response Fields

Field Type Description
access_token string JWT token for API authentication
token_type string Always "Bearer"
expires_in integer Token lifetime in seconds
refresh_token string Token for refreshing access

Code Examples

PHP

$response = $client->post('https://api.apimw.com/v1/auth/token', [
    'json' => [
        'api_key' => 'your_api_key',
        'api_secret' => 'your_api_secret'
    ]
]);

$data = json_decode($response->getBody(), true);
$accessToken = $data['data']['access_token'];

Node.js

const response = await fetch('https://api.apimw.com/v1/auth/token', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: 'your_api_key',
    api_secret: 'your_api_secret'
  })
});

const { data } = await response.json();
const accessToken = data.access_token;

Python

import requests

response = requests.post('https://api.apimw.com/v1/auth/token', json={
    'api_key': 'your_api_key',
    'api_secret': 'your_api_secret'
})

data = response.json()
access_token = data['data']['access_token']