API · documentation

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.

  1. Open the web app, log in, and create a key in the API keys tab. It is shown once: copy it.
  2. Check it:

Authentication

Every call carries the key in one of these two headers:

X-API-Key: lt_…
Authorization: Bearer lt_…
ScopeWhat it allows
readAll GET routes, plus POST /api/plan and POST /api/wizard/count, which change nothing.
fullEverything, including starting exports (POST /api/export, POST /api/jobs).
adminCreating 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.

ParameterDefaultMeaning

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 — by default the export is a test: the numbers stay available in the wizard and can come out again. With 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:

  1. POST /api/plan — preview the split (nothing is exported).
  2. POST /api/jobs — start the export: the answer comes at once, with an id.
  3. GET /api/jobs/{id} every few seconds until status is done, then GET /api/jobs/{id}/csv.

Two ways to set the amounts:

  • Fixed total — n_numbers: split between departments in proportion to leads_by_dept. Skipped departments give their share to the others.
  • Multiplier — multiplier: each department gets its request × multiplier (n_numbers is 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": "…"}.

CodeMeaning
400Impossible request: every department under the minimum, nothing to export…
401Key missing, wrong or revoked (or web session expired)
403read key on a route that exports, or a key trying to manage keys
404Unknown export or route
409An export is already running
422Invalid parameter: the answer says which one (detail[].loc, detail[].msg)
502Data Center Pro or the wizard refused or didn't answer, or the export failed

Loading the reference…