Lead tools API
Everything the web app does can be done by a program: remaining leads to deliver, availability in the wizard, and exports of numbers by department as one CSV file.
Quick start
Base address: . Everything is JSON (UTF-8), except the CSV downloads.
- Open the web app, log in, and create a key in the API keys tab. It is shown once: copy it.
- Check it:
Authentication
Every call carries the key in one of these two headers:
X-API-Key: lt_…
Authorization: Bearer lt_…
| Scope | What it allows |
|---|---|
| read | All GET routes, plus POST /api/plan and POST /api/wizard/count, which change nothing. |
| full | Everything, including starting exports (POST /api/export, POST /api/jobs). |
| admin | Creating and revoking keys: only from the web page, logged in. A key can't manage keys. |
One key per program or person: if it leaks, revoke it in the web page without touching the others; programs using it get 401 immediately. Keep keys on the server side (scripts, back ends), never in code sent to a browser.
Export in one call
POST /api/export does everything and answers with the CSV. Nothing to send: the departments and their requests come from Data Center Pro (leads remaining to deliver), and every parameter has a default.
| Parameter | Default | Meaning |
|---|
Change any of them in the address, e.g. /api/export?multiplier=100&mark=true. The call lasts as long as the export (minutes for a big one): use a long timeout. Response headers: X-Job-Id (the export, also visible in the web page) and X-Numbers.
mark=true they are marked as used and never come out again.Export in the background
To choose the departments yourself, or follow the progress, use the three-step flow:
POST /api/plan— preview the split (nothing is exported).POST /api/jobs— start the export: the answer comes at once, with anid.GET /api/jobs/{id}every few seconds untilstatusisdone, thenGET /api/jobs/{id}/csv.
Two ways to set the amounts:
- Fixed total —
n_numbers: split between departments in proportion toleads_by_dept. Skipped departments give their share to the others. - Multiplier —
multiplier: each department gets its request × multiplier (n_numbersis ignored).
In both, share_without_dept is the share of the total without department, and departments that would get fewer than min_per_dept numbers are skipped. One export runs at a time: a second one gets 409.
The CSV file
numero,departement
0612345678,77
0798765432,91
0645678901,0
Comma-separated, UTF-8, one header line. departement is 0 for numbers without department. Number format: fmt — national 0612…, brut 33612…, e164 +33612….
Behind the scenes, the wizard can't take an amount per department in one lot: the app exports one wizard lot per department and merges them into this single file. With only_new=true, every number already exported today in the wizard (by anyone) is left out and replaced; the first such export of the day downloads today's lots once, which can take several minutes.
Errors
On failure the answer is JSON with an explicit HTTP code: {"detail": "…"} or {"error": "…"}.
| Code | Meaning |
|---|---|
| 400 | Impossible request: every department under the minimum, nothing to export… |
| 401 | Key missing, wrong or revoked (or web session expired) |
| 403 | read key on a route that exports, or a key trying to manage keys |
| 404 | Unknown export or route |
| 409 | An export is already running |
| 422 | Invalid parameter: the answer says which one (detail[].loc, detail[].msg) |
| 502 | Data Center Pro or the wizard refused or didn't answer, or the export failed |
Loading the reference…