Sandbox
Build and test your integration against the real endpoints without spending a token or touching real data.
What the sandbox is
A sandbox key works on the same address and the same four endpoints as a live key. The difference is the answer: the sandbox checks your request the way a live call does, then returns a fixed sample answer.
| Sandbox key | Live key | |
|---|---|---|
| Tokens | Never used | Enroll and identify use one token on success |
| Photo | Checked for presence and size, never analysed | Sent to the identification model |
| Your cows | Nothing is saved; list always returns the same sample cows | Saved and searched |
| Usage log | Not recorded | Recorded |
| Input checks | Same as live: missing file, bad top_k, bad cow_id and so on | Same |
| Account approval | Not needed | Needed to create a key |
| Rate limits | None | 60 requests a minute |
Every sandbox response carries the header X-Sandbox: true, so you can tell it apart from a live one.
Get a sandbox key
Sign in
Open the API access page of your dashboard.
Create a sandbox key
Choose Create sandbox key. You can have 5 active at a time. Copy it; it is shown once.
Send a request
Use it in the
X-API-Keyheader exactly like a live key. Nothing else changes in your code.
What you get back
Successful calls return a fixed sample in the platform's JSON envelope. The sample herd is BD-0001, BD-0002 and BD-0003, and identify returns candidates from it with falling scores.
Identify with top_k=3
Response body.
{
"is_success": true,
"message": "Search complete.",
"data": {
"matches": [
{
"cow_id": "BD-0001",
"score": 0.97
},
{
"cow_id": "BD-0002",
"score": 0.91
},
{
"cow_id": "BD-0003",
"score": 0.84
}
]
}
}
Trigger an error on purpose
Send the X-Sandbox-Scenario header with a sandbox key to get a platform error and test how your code reacts. A live key ignores this header.
| Value | Result |
|---|---|
| no_tokens | 402: no tokens of the needed type left (enroll and identify only) |
| rate_limit | 429: rate limit reached, with a Retry-After header |
| upstream_down | 502: the model could not be reached, nothing charged |
Simulate running out of tokens
cURL
curl -X POST https://api.central.pranisheba.com.bd/identify \
-H "X-API-Key: YOUR_SANDBOX_KEY" \
-H "X-Sandbox-Scenario: no_tokens" \
-F file=@muzzle.jpg
Python
import requests
response = requests.post(
"https://api.central.pranisheba.com.bd/identify",
headers={"X-API-Key": "YOUR_SANDBOX_KEY", "X-Sandbox-Scenario": "no_tokens"},
files={"file": open("muzzle.jpg", "rb")},
timeout=(10, 180),
)
print(response.status_code, response.json())
JavaScript
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("file", new Blob([await readFile("muzzle.jpg")], { type: "image/jpeg" }), "muzzle.jpg");
const response = await fetch("https://api.central.pranisheba.com.bd/identify", {
method: "POST",
headers: { "X-API-Key": "YOUR_SANDBOX_KEY", "X-Sandbox-Scenario": "no_tokens" },
body: form,
});
console.log(response.status, await response.json());
Errors the identification model raises itself, such as a blurry photo, a duplicate cow id or a duplicate muzzle, cannot be simulated.
Going live
- Buy tokens on the Buy tokens page. Your first paid purchase approves your account.
- Create a live key on the API access page.
- Replace the sandbox key with the live key. The address, parameters and code stay the same.
- Check
is_successand the HTTP status on every response, and handle 402 and 429. Live responses come from the identification model and may carry fields the sample does not show.