Issue an access token
Exchange API key credentials for a short-lived ES256 JWT access token. Authenticate with HTTP Basic: the username is the API key’s client_id (a UUID) and the password is its client_secret. Send the returned access_token as Authorization: Bearer <token> on every subsequent Platform API call.
POST
/
tokens
Issue an access token
curl --request POST \
--url https://api-{programRef}.sandbox.paylead.tech/tokens \
--header 'Authorization: Basic <encoded-value>' \
--header 'x-api-version: <x-api-version>'import requests
url = "https://api-{programRef}.sandbox.paylead.tech/tokens"
headers = {
"x-api-version": "<x-api-version>",
"Authorization": "Basic <encoded-value>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-version': '<x-api-version>', Authorization: 'Basic <encoded-value>'}
};
fetch('https://api-{programRef}.sandbox.paylead.tech/tokens', 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-{programRef}.sandbox.paylead.tech/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"x-api-version: <x-api-version>"
],
]);
$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-{programRef}.sandbox.paylead.tech/tokens"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-version", "<x-api-version>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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-{programRef}.sandbox.paylead.tech/tokens")
.header("x-api-version", "<x-api-version>")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-{programRef}.sandbox.paylead.tech/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-version"] = '<x-api-version>'
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhcGkta2V5In0.sig",
"expires_in": 3600,
"token_type": "Bearer"
}{
"code": "PL-4XX-YY",
"status": 400,
"title": "The request was invalid.",
"errors": [
{
"loc": [
"body",
"field"
],
"msg": "Field required",
"type": "missing"
}
],
"instance": "api/resource/424242"
}{
"code": "PL-4XX-YY",
"status": 400,
"title": "The request was invalid.",
"errors": [
{
"loc": [
"body",
"field"
],
"msg": "Field required",
"type": "missing"
}
],
"instance": "api/resource/424242"
}Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Headers
Selects the partner API version to use, in semver form x.y.z (e.g. 2.0.0). Required.
Was this page helpful?
⌘I
Issue an access token
curl --request POST \
--url https://api-{programRef}.sandbox.paylead.tech/tokens \
--header 'Authorization: Basic <encoded-value>' \
--header 'x-api-version: <x-api-version>'import requests
url = "https://api-{programRef}.sandbox.paylead.tech/tokens"
headers = {
"x-api-version": "<x-api-version>",
"Authorization": "Basic <encoded-value>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-version': '<x-api-version>', Authorization: 'Basic <encoded-value>'}
};
fetch('https://api-{programRef}.sandbox.paylead.tech/tokens', 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-{programRef}.sandbox.paylead.tech/tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"x-api-version: <x-api-version>"
],
]);
$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-{programRef}.sandbox.paylead.tech/tokens"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("x-api-version", "<x-api-version>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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-{programRef}.sandbox.paylead.tech/tokens")
.header("x-api-version", "<x-api-version>")
.header("Authorization", "Basic <encoded-value>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-{programRef}.sandbox.paylead.tech/tokens")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-version"] = '<x-api-version>'
request["Authorization"] = 'Basic <encoded-value>'
response = http.request(request)
puts response.read_body{
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhcGkta2V5In0.sig",
"expires_in": 3600,
"token_type": "Bearer"
}{
"code": "PL-4XX-YY",
"status": 400,
"title": "The request was invalid.",
"errors": [
{
"loc": [
"body",
"field"
],
"msg": "Field required",
"type": "missing"
}
],
"instance": "api/resource/424242"
}{
"code": "PL-4XX-YY",
"status": 400,
"title": "The request was invalid.",
"errors": [
{
"loc": [
"body",
"field"
],
"msg": "Field required",
"type": "missing"
}
],
"instance": "api/resource/424242"
}