Skip to contentSkip to Content
API ReferencePOSTGet access token

Get access token

Obtain access tokens for authenticating API requests.

Get a token

Exchange your API credentials for a JWT access token.

POST/business/auth

Request body

FieldTypeRequiredDescription
apiKeystringYesYour API key
apiSecretstringYesYour API secret

Example request

cURL
curl -X POST https://api.test.wakapay.io/business/auth \ -H "Content-Type: application/json" \ -d '{ "apiKey": "your_api_key", "apiSecret": "your_api_secret" }'

Success response

Status Code: 200 OK

{ "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.****...****", "expiresIn": 3600 }

Response fields

FieldTypeDescription
accessTokenstringJWT access token to use for authenticated requests
expiresInnumberToken validity duration in seconds (3600 = 1 hour)

Errors

400 - Missing Credentials

Missing apiKey or apiSecret fields:

{ "code": 0, "error": "apiKey and apiSecret required" }

400 - Empty Credentials

Empty apiKey or apiSecret values:

{ "code": 0, "error": "apiKey and apiSecret required" }

400 - Invalid Payload

Malformed JSON or wrong Content-Type:

{ "code": 0, "error": "invalid payload" }

Common Causes:

  • Invalid JSON syntax
  • Missing Content-Type: application/json header
  • Sending non-JSON data

401 - Invalid Credentials

Wrong apiKey or apiSecret:

{ "code": 0, "error": "invalid credentials" }

Using the token

Include the access token in the Authorization header of all subsequent API requests:

Authorization: Bearer YOUR_ACCESS_TOKEN

Example

cURL
curl https://api.test.wakapay.io/business/balance?currency=USD \ -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Token best practices

Caching tokens

Cache tokens in memory and reuse them until they expire, so you don’t make unnecessary authentication requests.

Handling expiry

When you receive a 401 Unauthorized error, clear your cached token, request a new one, and retry the call once.

Security

  • Never log tokens: Tokens are sensitive and should never be logged or exposed
  • Use HTTPS: Always use HTTPS endpoints to prevent token interception
  • Store securely: Never commit API keys or secrets to version control
  • Environment variables: Store credentials in environment variables
  • Separate environments: Use different keys for test and production

Token expiry

  • Duration: Tokens expire after 3600 seconds (1 hour)
  • Refresh: Request a new token before the current one expires
  • Buffer: Implement a 60-second buffer before expiry to prevent edge cases