Skip to main content
POST
/
generate-token
cURL
curl --request POST \
  --url https://api.clickpesa.com/third-parties/generate-token \
  --header 'api-key: <api-key>' \
  --header 'client-id: <client-id>'
import requests

url = "https://api.clickpesa.com/third-parties/generate-token"

headers = {
"client-id": "<client-id>",
"api-key": "<api-key>"
}

response = requests.post(url, headers=headers)

print(response.text)
const options = {method: 'POST', headers: {'client-id': '<client-id>', 'api-key': '<api-key>'}};

fetch('https://api.clickpesa.com/third-parties/generate-token', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.clickpesa.com/third-parties/generate-token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"api-key: <api-key>",
"client-id: <client-id>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.clickpesa.com/third-parties/generate-token"

req, _ := http.NewRequest("POST", url, nil)

req.Header.Add("client-id", "<client-id>")
req.Header.Add("api-key", "<api-key>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.clickpesa.com/third-parties/generate-token")
.header("client-id", "<client-id>")
.header("api-key", "<api-key>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.clickpesa.com/third-parties/generate-token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["client-id"] = '<client-id>'
request["api-key"] = '<api-key>'

response = http.request(request)
puts response.read_body
{
  "success": true,
  "token": "Bearer token"
}
{
"message": "Unauthorized"
}
{
"message": "Invalid or Expired API-Key"
}
JTW token is valid for 1 hour from the time of issuance. After it expires, you must generate a new token.

Headers

client-id
string
required

Your Application Client ID.

api-key
string
required

Your Application API Key.

Response

Generate token response

success
boolean
required
Example:

true

token
string
required
Example:

"Bearer token"