Jtl
service_jtl — Endpoints: JTL¶
Base prefix: /api/v1/jtl
Core routes for JTL integration, credential management, inbound creation and evaluation downloads.
Auth / credential management¶
GET /oauth/callback?code=...&state=...- Called by JTL after user consent. Exchanges
codefor tokens and persists them to the credential record referenced bystate. -
Example:
GET /api/v1/jtl/oauth/callback?code=...&state=... -
GET /auth_url/{credential_id} - Returns an authorization URL for the given credential record (user must visit it and approve access).
-
Response:
{"auth_url": "https://..."} -
POST /credentials/ - Create a new JTL credential. Body model:
JTLCredentialsCreate(seebackend/service_jtl/app/models/jtl.py). -
Example body:
{ "name": "Inbound JTL", "client_id": "<client-id>", "client_secret": "<secret>", "callback_url": "https://dashboard.example/api/v1/jtl/oauth/callback", "scopes": ["ffn.merchant.read"] } -
PUT /credentials/{credential_id}— Update credential metadata (JTLCredentialsUpdate). DELETE /credentials/{credential_id}— Remove a credential.GET /credentials/— List stored credentials.POST /credentials/{credential_id}/toggle-active— Toggle which credential is active for background jobs.GET /credentials/{credential_id}/get_token— Ensure a bearer token exists (exchange code if necessary) and return it.GET /credentials/{credential_id}/is_valid— Test token validity and attempt refresh if needed.
Processing endpoints¶
POST /run-check/- Run the checker processing pipeline for a provided
RunCheckRequest(fields:start_date,end_date,delivery_time_add). - Uses
Jtl_Manager.process_checkers()and writes a JSON eval result toevals/.
Example request body:
{
"start_date": "2026-05-01T00:00:00",
"end_date": "2026-05-31T23:59:59",
"delivery_time_add": 2
}
-
POST /create-inbounds/— Create inbounds for a given date (defaults to yesterday Berlin time). Accepts{ "date": "YYYY-MM-DD" }in the JSON body or query. -
GET /eval/download/{filename}— Download eval JSON files produced byrun-check. GET /eval/list— List available eval files inevals/.
Cron management¶
POST /cron/start?schedule=<cron_expr>— Create/replace scheduled cron job for inbound monitoring (usesCronJobManager.upsert_job).POST /cron/stop— Stop the cron job.GET /cron/status— Return scheduling metadata (last run, next run) persisted byCronJobManager.
WebSocket¶
WS /ws— Real-time socket used for progress and callback notifications (e.g., OAuth success alerts).
Implementation¶
- Endpoint implementation: backend/service_jtl/app/api/v1/endpoints/jtl.py
- JTL client: backend/service_jtl/app/services/jtl/jtl.py
- OAuth helper: backend/service_jtl/app/services/jtl/jtl_credentials.py
- Cron manager: backend/service_jtl/app/services/cron_service.py
Operational notes¶
- Authentication: most endpoints are protected by JWT in
main.py's middleware; callback and public routes are exempted viaPUBLIC_ENDPOINTS. create-inboundsandrun-checkare used by the scheduler and by manual API calls; returned results are stored inevals/for auditing and download.process_inboundscontains retry and error-handling heuristics: missing products are removed and retried, and the inbound number may be retried with a(2)suffix if JTL rejects it.