KrezyPay API
  • πŸ‘‹Welcome to KrezyPay API
  • Environment
  • Authentification
  • Customer
    • πŸ‘¨Create a customer
    • πŸ‘¨Retrieve Customer
  • Card
    • πŸ’³Create card
    • πŸ’³Retrieve Card
    • πŸ’³Fund Card
    • Authorization Transaction
    • Withdraw fund
    • Freeze/Unfreeze
    • Transaction
    • Countries we support
  • Topup
    • βœ…Topup Shema
    • βœ…Estimate
    • βœ…Send
  • SMS
    • πŸ“ΆSMS Shema
    • πŸ“ΆSend SMS
    • Supporting country
  • Production Access
  • ❌Errors
    • πŸ“ŽError
Powered by GitBook
On this page
  • πŸ”‘ Getting an API Key
  • Generate your first token

Authentification

PreviousEnvironmentNextCustomer

Last updated 7 months ago

πŸ”‘ Getting an API Key

  1. Sign up or log in to your sandbox account at:

  2. Navigate to Settings > Developer Setting

  3. Complete your developer profile

πŸŽ‰ Make your first request

Generate your first token

POST

Body

Name
Type
Description

public_key

string

The public key issued by the system

secret_key

string

The secret key issued by the system

Response


{
    "token_type": "Bearer",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vYXBpLmtyZXp5cGF5LmNvbSIsImlhdCI6MTcyOTAyMTI2NCwiZXhwIjoxNzI5MTA3NjY0LCJ1c2VyX2lkIjoiRGZZOW82VDlSM2x5Z21qTjNwQXBWMXVXMjB4MTloSzEwd0NRNjJ4UzhNbmRsN2RJYnlpa1hmdmF6d1VjOHJCaWU0cU9FdHQ4Wm5nNmVjcTI3Rkc1YXI0anNoc3ZMbWI3ejRIMzUwUG9KazV1In0.Fg92V5ZK-eKqTPXP-kPehvechFGZOBcHlTvOwj9nYAI",
    "expires_in": 86400
}
 
{
  "error": "Invalid request"
}

See Examples Below

const url = 'https://api.krezypay.com/v1/sandbox/token';

const data = {
  public_key: "pk_G85mdzusjlK...",
  secret_key: "sk_7d03871lQ5..."
};

fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
<?php

$url = 'https://api.krezypay.com/v1/sandbox/token';

$data = [
    'public_key' => 'pk_G85mdzusjlKyUhA97oc4ter4Spk2I6aOF382cqznyZYmxtHpWJ0f6P3Mj5L0Rr7gXbuk15gfvEwoxi3970badlDn1CwqThVB264i8se9vN1Q',
    'secret_key' => 'sk_7d03871lQ5LfE9ewcHdjr6b2oPtTZAbV8k0Mnu0p54Si21G6ONi9xxIhXzDmaqy465Fe9o4lt3YafwuBvyzKmchCgsqn7sWr1j83vJR2Upgk'
];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);

if ($response === false) {
    echo 'Erreur cURL: ' . curl_error($ch);
} else {
    echo 'RΓ©ponse: ' . $response;
}

curl_close($ch);
import requests
import json

url = 'https://api.krezypay.com/v1/sandbox/token'

data = {
    "public_key": "pk_G85mdzusjlKyUhA97oc4ter4Spk2I6aOF382cqznyZYmxtHpWJ0f6P3Mj5L0Rr7gXbuk15gfvEwoxi3970badlDn1CwqThVB264i8se9vN1Q",
    "secret_key": "sk_7d03871lQ5LfE9ewcHdjr6b2oPtTZAbV8k0Mnu0p54Si21G6ONi9xxIhXzDmaqy465Fe9o4lt3YafwuBvyzKmchCgsqn7sWr1j83vJR2Upgk"
}

headers = {
    'Content-Type': 'application/json'
}

response = requests.post(url, headers=headers, data=json.dumps(data))

if response.status_code == 200:
    print('RΓ©ponse:', response.json())
else:
    print(f'Erreur {response.status_code}: {response.text}')

Congrats, you've authenticated and made your first request!

The token is valid for 24 hours

https://business.krezypay.com/login
https://api.krezypay.com/v1/sandbox/token