Generate API Key
POST
/api/v1/lead_providers/{id}/generate_api_key/Generates a new API key (credential) for a specific provider and stores it in the database in hashed form.
Auth: Admin JWT + IsAdminOnlyPosition.
Path parameter
| Parameter | Type | Description |
|---|---|---|
id | Integer | Provider ID |
Body fields
| Field | Type | Required | Description |
|---|---|---|---|
name | String | Optional | Key name ("Production", "Sandbox"). Default: "default" |
Response — 200 / 201
{
"api_key": "lp_live_7f2a91_r3vS6gG8-QzM5h...",
"credential_id": 1,
"key_prefix": "7f2a91"
}
| Field | Description |
|---|---|
api_key | The full key — shown only in this response |
credential_id | The key record ID (for managing keys) |
key_prefix | The public prefix of the key (for identification; not secret) |
:::danger Security — the key is shown only once
api_key is returned only once. The system does not store it in plain text (hash).
If lost, it cannot be recovered; you must generate a new one and revoke the old one.
Deliver the key to the provider over a secure channel (don't paste it in email/chat).
:::
Code samples
- curl
- JavaScript
- Python
curl -X POST https://api.navigo.example/api/v1/lead_providers/1/generate_api_key/ \
-H "Authorization: Bearer $NAVIGO_ADMIN_JWT" \
-H "Content-Type: application/json" \
-d '{"name": "Production"}'
const res = await fetch(
"https://api.navigo.example/api/v1/lead_providers/1/generate_api_key/",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.NAVIGO_ADMIN_JWT}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ name: "Production" }),
},
);
const { api_key, key_prefix } = await res.json();
// Store api_key securely — it will not be shown again.
import os, requests
resp = requests.post(
"https://api.navigo.example/api/v1/lead_providers/1/generate_api_key/",
headers={"Authorization": f"Bearer {os.environ['NAVIGO_ADMIN_JWT']}"},
json={"name": "Production"},
timeout=15,
)
resp.raise_for_status()
data = resp.json()
api_key = data["api_key"] # only here; store it securely
Possible errors
| Status | Reason |
|---|---|
404 | No provider with this id |
401 | JWT is invalid |
403 | No admin position |
Full format: Errors.