Authentication
Authenticate every request with your API key as a Bearer token
The Voice213 API authenticates requests with API keys. Send your key as a Bearer token in the Authorization header of every request:
curl -X POST https://api.voice213.com/api/v1/tts \
-H "Authorization: Bearer $VOICE213_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "مرحبا بيكم", "model": "voice213-lite", "voice": "nariman"}'import os
import requests
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['VOICE213_API_KEY']}"
response = session.post(
"https://api.voice213.com/api/v1/tts",
json={"text": "مرحبا بيكم", "model": "voice213-lite", "voice": "nariman"},
timeout=300,
)const response = await fetch("https://api.voice213.com/api/v1/tts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.VOICE213_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ text: "مرحبا بيكم", model: "voice213-lite", voice: "nariman" }),
});You can send the key in an x-api-key header instead:
curl https://api.voice213.com/api/v1/me -H "x-api-key: $VOICE213_API_KEY"When a request has both headers, the Authorization header wins. Write Bearer with a capital B: with any other spelling, Voice213 ignores the header.
Who can use the API
Everyone. The API is open on every plan, Free included, and every key gets the same limits. What you need is API credit: a prepaid balance in dinars that pays for your voice-overs, separate from your plan's credits. A key keeps working whatever happens to your plan.
Your API key
- Create your key on the API Keys page of the Developer workspace.
- A key starts with
sk_live_. It's shown once, when you create it; afterwards the page shows only its last eight characters. A lost key can't be shown again: delete it and create a new one. - An account has one API key. To replace it, delete the old one first.
- You can switch the key off and on again. While it's off, requests that use it are refused.
- Voice213 can switch off API access for an account. Its key is then refused with
403and the codeAPI_ACCESS_BLOCKED, and it can't create a key or switch one back on. See API access switched off. - The API Keys page shows when the key last made a successful voice-over (estimates,
GET /meand the catalogue endpoints don't update it). Usage shows your calls day by day.
Deleting a key
Delete the key on the API Keys page when it's no longer needed or may have leaked. It stops working immediately, and requests that use it get 401 Invalid or inactive API key. This can't be undone.
Authentication errors
| Status | Error | Cause |
|---|---|---|
401 | Missing API key. Pass it as 'Authorization: Bearer sk_live_...' | The request has no key: no Authorization: Bearer header and no x-api-key header. |
401 | Invalid or inactive API key | The key is wrong, incomplete, switched off or deleted. |
403 | Account deactivated | The account that owns the key is deactivated or suspended. Contact support. |
403 | API_ACCESS_BLOCKED (in code) | API access is switched off for the account that owns the key. The message in error is in Arabic. Contact support. |
429 | Rate limit exceeded: RPM limit exceeded | The key reached its requests per minute. See Rate Limits. |
429 | Rate limit exceeded: Daily limit exceeded | The key reached its requests per day. |
429 | Rate limit exceeded: Concurrent request limit exceeded | The key already has 20 voice-overs running (POST /tts only). |
500 | Internal server error during authentication | Something went wrong on our side while checking the key. Retry. |
Keeping keys safe
An API key gives full access to your API credit. Keep it secret.
- Store the key in an environment variable or a secret manager, never in source code.
- Use it only in server-side code. Never put it in websites, mobile apps or anything else you ship to users.
- If the key may have leaked, switch it off right away, then delete it and create a new one.
Was this page helpful?