Skip to content

Request an access token

POST
/Auth/RequestToken
curl --request POST \
--url https://cybqa.pesapal.com/pesapalv3/api/Auth/RequestToken \
--header 'Content-Type: application/json' \
--data '{ "consumer_key": "example", "consumer_secret": "example" }'

Exchanges a consumer key and secret for a bearer token valid for 60 minutes. Cache the token rather than requesting one per call.

Content-Type: application/json is mandatory. Omitting it returns HTTP 415 with a plain-text message rather than the usual error body.

Media typeapplication/json
object
consumer_key
required
string
consumer_secret
required
string
Examplegenerated
{
"consumer_key": "example",
"consumer_secret": "example"
}

Returned for both success and failure. A successful response carries token; a failed one carries error.

Media typeapplication/json
One of:
object
token
required

A JWT. Its exp claim is an integer and easier to parse than expiryDate.

string
expiryDate

UTC, with a Z and seven fractional-second digits. That precision is rejected by some strict parsers, including Python’s datetime.fromisoformat before 3.11.

string
error
null
status
string
message
string
Examples

Token issued

{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiryDate": "2026-09-03T12:08:08.5585879Z",
"error": null,
"status": "200",
"message": "Request processed successfully"
}

The Content-Type header was missing.

Media typeapplication/json

Returned by HTTP 404, 405 and 415, before the request reaches the application. Carries a plain-text message and no error object.

object
message
string
Examplegenerated
{
"message": "example"
}