Tsara provides simple RESTful APIs that can be accessed from any programming language that supports HTTP requests.
To make integration faster, you can use prebuilt snippets or your preferred HTTP client (like axios, requests, or cURL).
This section provides code examples in cURL, JavaScript, and PHP — the most common stacks for Tsara integrations.
🚀 Base Setup
Base URLs
| Environment | Base URL | Description |
|---|---|---|
| Production | https://api.tsara.ng/v1 | Live environment for real payments and transfers. |
| Sandbox | https://sandbox.tsara.ng/v1 | Safe environment for testing and development. |
🔑 Authentication
All requests must include your API key as a Bearer token in the Authorization header.
Header Example
Authorization: Bearer YOUR_SECRET_KEY
Content-Type: application/json💡 You can create and manage API keys from the Tsara Dashboard → Developers → API Keys.
⚡ Example — cURL
curl -X GET "https://sandbox.tsara.ng/v1/wallets" \
-H "Authorization: Bearer sk_test_xxxxxxx" \
-H "Content-Type: application/json"⚙️ Example — JavaScript (Node.js)
Using Axios:
import axios from "axios";
const TSARA_API_KEY = "sk_test_xxxxxxx";
const client = axios.create({
baseURL: "https://sandbox.tsara.ng/v1",
headers: {
"Authorization": `Bearer ${TSARA_API_KEY}`,
"Content-Type": "application/json"
}
});
// Example: Fetch all wallets
async function getWallets() {
try {
const res = await client.get("/wallets");
console.log(res.data);
} catch (err) {
console.error(err.response?.data || err.message);
}
}
getWallets();🧩 Example — PHP
Using the built-in cURL functions or any modern HTTP library.
<?php
$apiKey = "sk_test_xxxxxxx";
$url = "https://sandbox.tsara.ng/v1/wallets";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
print_r($data);
?>🧠 Pro Tips
- Use the Sandbox — Always test with
https://sandbox.tsara.ng/v1before going live. - Store API Keys Securely — Never expose your keys in frontend or client code.
- Use Environment Variables — Load keys from
.envor system variables. - Handle Webhooks Properly — Always verify
X-Tsara-Signaturefor all incoming events. - Retry on 5xx Errors — Implement exponential backoff for server errors.
🔗 Official Repositories
| Language | Repo | Status |
|---|---|---|
| PHP SDK | Coming soon | 🚧 In development |
| JavaScript SDK | Coming soon | 🚧 In development |
| Python SDK | Coming soon | 🚧 In development |
Until SDKs are published, you can use the Postman Collection or the examples provided here.
🧾 Postman Collection
You can import the official Tsara Postman Collection to explore and test all endpoints quickly.
File: tsara-postman-collection.json
How to use:
- Open Postman → Import → Upload File.
- Select the JSON file generated for Tsara.
- Configure your API Key under Authorization → Bearer Token.
🧩 Related Pages
- Authentication — Learn how to authorize every request.
- Errors — Understand and handle API errors gracefully.
- Webhooks — Securely process real-time events.