01
Set up a client
Every request is HTTPS to one base URL with your API key as a bearer token. The key decides the mode: tz_test_… talks to the sandbox, tz_live_… moves real money. The URL is the same for both.
Call Tizon from your server, not from your mobile app, so the key never ships to a device.
// tizon.js: a tiny client. Node 18+ has fetch built in,
// so there's no SDK to install.
const BASE_URL = 'https://api.tizon.mobile';
export async function tizon(method, path, body, options = {}) {
const res = await fetch(BASE_URL + path, {
method,
headers: {
// tz_test_… in the sandbox, tz_live_… in production.
Authorization: `Bearer ${process.env.TIZON_API_KEY}`,
'Content-Type': 'application/json',
...(options.idempotencyKey && {
'Idempotency-Key': options.idempotencyKey,
}),
},
body: body && JSON.stringify(body),
});
const data = await res.json();
if (!res.ok) {
// Every error is { error: { type, code, message, request_id } }
throw Object.assign(new Error(data.error.message), data.error);
}
return data;
}# .env: your sandbox key.
# Keep it on your server, never in a mobile app.
TIZON_API_KEY=tz_test_51b3f0c2a7d94e8a9c6e2f1d