29 - Developer and integrations

Navigation: Index | previous: 28 - Customer portal | next: the page index (99-page-index.md) Last checked against the application: 25 Nov 2026

1. Who this guide is for

This guide is for the company admin or the developer who connects the company's own systems to Traincu: an ERP, an accounting package, a warehouse or TMS, a GPS provider. It is written in plain words, with a few technical lines where a developer needs them.

2. What you can do here (summary)

Activity Who Screen(s)
Make, rotate or revoke an API key integrations.keys C-16 keys tab
Read your loads, shipments, trucks and drivers from your own system A system holding a key with the scope Public API
Add a webhook, test it, read its deliveries, retry one integrations.webhooks C-16 webhooks tab
Check the signature of a webhook A developer (your code)
Connect a GPS or tracking provider account and map devices to trucks integrations.connections C-16 connections tab
Pull invoices, trips and costs for accounting; map account and tax codes; read the sync log integrations.erp C-16 accounting tab
Switch Traincu's own providers on or off Traincu staff (settings.integrations) Settings > Integrations

3. Before you begin

4. Where to find it

Settings > API and webhooks (menu group "Messaging & links"). One page with four tabs; a tab you may not open is hidden.

Tab Address Permission
API keys /settings/integrations/keys integrations.keys
Webhooks /settings/integrations/webhooks integrations.webhooks
Connections /settings/integrations/connections integrations.connections
Accounting /settings/integrations/accounting integrations.erp

The public API itself is at https://<your Traincu address>/api/v1/public. Its description, GET /api/v1/public/openapi.json, is built from the code and can be loaded into any API tool.

5. The big picture (flowchart)

flowchart TD
  s1(["Company admin opens Settings > API and webhooks"]) --> d1{"What do you need?"}
  d1 -->|"Read data from my system"| k1["API keys: make a key with scopes"]
  d1 -->|"Be told when something happens"| w1["Webhooks: add an HTTPS endpoint and events"]
  d1 -->|"Bring truck positions in"| g1["Connections: add the GPS provider account"]
  d1 -->|"Feed my accounting system"| e1["Accounting: feeds, mapping, sync log"]
  k1 --> k2[["Public API: loads, shipments, trucks, drivers, feeds"]]
  w1 --> w2[["Traincu sends signed events to your endpoint"]]
  g1 --> g2[["Positions reach live tracking"]]
  e1 --> k2
  e1 --> w3[["export.ready tells your system a window is worth reading"]]
  k2 --> o1[/"Your ERP, TMS or accounting system"/]
  w2 --> o1

6. Activities, step by step

6.1 Make, rotate or revoke an API key (C-16, API keys tab)

Purpose - give one outside system read access to your company's data, with only the scopes it needs. Who - integrations.keys.

Steps

  1. Open Settings > API and webhooks > API keys. The list shows Key, Type (Live or Test), Scopes, Created, Last used, Status. Filters: Type, Status.
  2. Press New API key. In the window fill Name (for example "ERP" or "warehouse system"), Environment (a Test key is a separate key for trying your integration; it follows the same rules), tick the Scopes the system needs, set Calls per minute (default 60, between 10 and 1,000) and Expires (Never, In 30 days, In 90 days, In one year).
  3. Press Make the key. If you are asked, confirm your password or code.
  4. The next page shows the key once: trk_live_<prefix>_<secret> (or trk_test_...). Press Copy and keep it somewhere safe. Traincu keeps only a hash of it; if you lose it you must Rotate the key.
  5. Give the key to your developer. They send it on every call (see 6.2).
  6. Rotate makes a new secret at once and the old one stops; the new key is shown once. Revoke stops the key at once and cannot be undone; the row stays in the list as Inactive. A revoked or expired key cannot be rotated: make a new one.
flowchart TD
  s1(["Owner opens API keys"]) --> a1["Press New API key"]
  a1 --> a2["Name, environment, scopes, calls per minute, expiry"]
  a2 --> a3["Press Make the key"]
  a3 --> d1{"Scopes with amounts and your role cannot see money?"}
  d1 -->|"Yes"| a4["Refused: your role may not see amounts"] --> a2
  d1 -->|"No"| sys1[["Key made. Only its hash is stored"]]
  sys1 --> a5["Copy the key now: it is shown once"]
  a5 --> a6["Give it to your developer"]
  a6 --> o1[/"Their system calls the public API"/]
  o1 --> d2{"Lost, leaked or no longer needed?"}
  d2 -->|"Lost or leaked"| a7["Rotate: new secret, old key stops at once"] --> a5
  d2 -->|"Not needed"| a8["Revoke: the key stops at once"]
stateDiagram-v2
  [*] --> Active : key made
  Active --> Active : Rotate gives a new secret
  Active --> Expired : end date passes
  Active --> Inactive : Revoke

Fields (New API key)

Field What to enter Rules
Name What the key is for Required, 120 characters at most
Environment Live or Test Required
Scopes What the key may read At least one; money scopes need a role that sees amounts
Calls per minute The key's own limit 10 to 1,000; default 60
Expires Never, 30 days, 90 days, one year Optional

Scopes you can give today

Scope Opens
loads.read Load by code and the Traincu cargo types
shipments.read Shipment, its tracking, shipments waiting for a truck
vehicles.read Trucks, their compliance, trucks free in a window
drivers.read Drivers, their compliance, drivers free in a window
invoices.export, trips.export, costs.export The three accounting feeds (carry amounts)
invoices.read, documents.read Offered, but no address serves them yet

The write scopes (loads.write, shipments.write) are not offered: the public API is read-only in version 1.

Statuses

Status Meaning What you can do
Active The key works Rotate, Revoke
Expired Its end date passed Make a new key (a revoke is only tidying up)
Inactive Revoked Make a new key

If something goes wrong - "Tick at least one scope." / "Your role may not see amounts, so it cannot give a key the scopes that read them: ..." / "This API key was already revoked." / "A revoked API key cannot be rotated. Make a new key instead." / "An expired API key cannot be rotated. Make a new key instead."

6.2 Use the public API (for the developer)

Purpose - let your own system read your Traincu data. Who - any system holding a key with the right scope. It is read-only in version 1.

Basics

The addresses

Address Scope What it answers
GET /me none The company this key opens, its scopes, limit and end date, the server time
GET /openapi.json none The OpenAPI 3.1 description
GET /loads/{code} loads.read One load the company posted or was invited to (LD-0042, ld-42 and 42 all work)
GET /cargo-types loads.read Traincu cargo types; filter[active], filter[hazardous]
GET /shipments/{code} shipments.read One shipment the company ships or carries (SHP-2611-0123 or the id)
GET /shipments/{code}/track shipments.read Status, ETA, stop stamps and last position
GET /shipments/awaiting-truck shipments.read What the company won as a carrier and has not given a truck yet
GET /vehicles/{id} vehicles.read One truck of the company
GET /vehicles/{id}/compliance vehicles.read Its papers and TGA verdict on a day (on)
GET /vehicles/available vehicles.read Trucks free in a window: from, to, filter[vehicle_type_id], filter[include_blocked]
GET /drivers drivers.read Active drivers and helpers; filter[type] = driver (default), helper, all
GET /drivers/{id} drivers.read One person
GET /drivers/{id}/compliance drivers.read Papers and duty minutes left (on)
GET /drivers/available drivers.read Who can take work in a window: from, to, filter[include_blocked]
GET /exports/invoices, /exports/trips, /exports/costs invoices.export, trips.export, costs.export The accounting feeds (6.6)

A window is whole days in the company's clock; to defaults to from, both default to today, and 31 days is the most one call may ask for.

What the API never answers - by rule, not by accident: no phone number of a person (not a driver's mobile, not a stop contact); no identity number, date of birth, bank account or nationality of a driver (their licence and professional-card numbers are there: they are the employer's own papers); no street address of a load's stop (only an approximate pin, about a kilometre; a shipment's stops do carry the address because both parties already hold it); no anonymous shipper's name or id; no price a side may not read; no internal id of a record the API does not serve; no free text that was never declared; no translated sentence as data (findings carry a code and dates).

Errors are RFC 9457 problems (Content-Type: application/problem+json): type, title, status, detail, instance, code; a 422 adds errors. Switch your program on code; show title and detail to people (they follow your Accept-Language, Arabic first).

Status Code Meaning
401 missing_key No key was sent
401 invalid_key The key is not known
401 key_expired The key passed its end date
401 key_revoked The key was revoked
403 company_inactive The company behind the key is not active
403 insufficient_scope The key lacks the scope of this address
404 not_found No such record (or another company's)
405 method_not_allowed Only GET exists in version 1
422 validation_failed A bad filter, window or cursor; errors says which
429 rate_limited The key's calls a minute are used up; wait Retry-After
503 service_unavailable The owning module is not available
500 server_error Something broke on our side
flowchart TD
  s1(["Your system calls an address with the key"]) --> d1{"Key sent and known?"}
  d1 -->|"No"| e1(["401 missing_key or invalid_key"])
  d1 -->|"Yes"| d2{"Expired, revoked, or company not active?"}
  d2 -->|"Expired or revoked"| e2(["401 key_expired or key_revoked"])
  d2 -->|"Company not active"| e3(["403 company_inactive"])
  d2 -->|"No"| d3{"Key holds the scope of this address?"}
  d3 -->|"No"| e4(["403 insufficient_scope"])
  d3 -->|"Yes"| d4{"Calls this minute within the key limit?"}
  d4 -->|"No"| e5(["429 rate_limited with Retry-After"])
  d4 -->|"Yes"| d5{"Filters, window and cursor valid?"}
  d5 -->|"No"| e6(["422 validation_failed"])
  d5 -->|"Yes"| d6{"Record is this company's?"}
  d6 -->|"No"| e7(["404 not_found"])
  d6 -->|"Yes"| e8(["200 data, with the rate limit headers"])
sequenceDiagram
  participant S as Your system
  participant T as Traincu public API
  S->>T: GET /shipments/awaiting-truck with the key
  T-->>S: 200 data and meta next_cursor
  S->>T: same question with cursor
  T-->>S: 200 next page
  S->>T: GET /shipments/SHP-⁠2611-0123/track
  T-->>S: 200 status, ETA, last position

6.3 Add a webhook and follow its deliveries (C-16, Webhooks tab)

Purpose - be told by Traincu, in real time, when something happens. Who - integrations.webhooks. A company may hold at most 20 webhooks.

Steps

  1. Open the Webhooks tab. Columns: Name, Endpoint URL, Events, Status, Last delivery, Last answer, Failures in a row, Created. Filters: Status, Event.
  2. Press Add webhook. Fill Name, Endpoint URL (HTTPS only, on the public internet), Description, and tick the Events. Press Save.
  3. The next page shows the signing secret once (whsec_...). Press Copy. Only a fingerprint is shown later.
  4. Press Send test. Traincu sends a test delivery (webhook.test); the message says "The test delivery was received: the endpoint answered 200 in N ms." or why it failed.
  5. Read the Deliveries log of the webhook: Queued, Event, Status, Attempt, Answer, Why, ms, Next try, Delivered, Delivery id. Filters: Status, Event. Press Send again on a delivery to retry it.
  6. Switch off stops sending to the endpoint; Switch on restores it. Rotate secret makes a new secret; the old one keeps signing for 24 hours. Delete removes the webhook and its log.
flowchart TD
  s1(["Open the Webhooks tab"]) --> a1["Press Add webhook"]
  a1 --> a2["Name, HTTPS address, description, events"]
  a2 --> a3["Press Save"]
  a3 --> d1{"Address HTTPS and public? Event chosen? Under 20 webhooks?"}
  d1 -->|"No"| a4["Fix what the message says"] --> a2
  d1 -->|"Yes"| sys1[["Webhook saved. Secret shown once"]]
  sys1 --> a5["Copy the secret into your system"]
  a5 --> a6["Press Send test"]
  a6 --> o1[/"Your endpoint answers"/]
  o1 --> d2{"Answer 2xx?"}
  d2 -->|"No"| a7["Fix the endpoint and test again"] --> a6
  d2 -->|"Yes"| e1(["Real events now reach your endpoint"])

How a delivery travels

  1. Something happens in Traincu (for example a shipment is delivered). The event is recorded.
  2. Traincu finds every active webhook of each company named in the event that subscribed to it, and builds the body from that company's own view of the event (nothing the other side keeps private).
  3. It sends one POST per webhook: HTTPS, no private or local address (checked again at send time), no redirects, 3 seconds to connect and 10 seconds in all.
  4. A 2xx answer means Delivered. Anything else is tried again after 1 min, 5 min, 30 min, 2 h, 6 h, 12 h and 24 h (up to 8 attempts, about two days), then the delivery is Failed and stays in the log.
  5. After 20 failed deliveries in a row Traincu switches the webhook off (status Disabled) and tells the Owner. Fix the endpoint, then switch it on.
flowchart TD
  s1[["An event happens in Traincu"]] --> sys1[["Event is recorded once"]]
  sys1 --> sys2[["Active webhooks that subscribed are found"]]
  sys2 --> sys3[["Body is built from that company's own view"]]
  sys3 --> sys4[["POST to the endpoint with the signature, 10 seconds at most"]]
  sys4 --> d1{"Answer 2xx?"}
  d1 -->|"Yes"| e1(["Delivered. Failure count goes back to 0"])
  d1 -->|"No"| d2{"Fewer than 8 attempts?"}
  d2 -->|"Yes"| sys5[["Wait 1 min up to 24 h, then try again"]] --> sys4
  d2 -->|"No"| e2(["Delivery Failed, kept in the log"])
  e2 --> d3{"20 failures in a row?"}
  d3 -->|"Yes"| sys6[["Webhook Disabled. Owner is told"]]
  d3 -->|"No"| e3(["Webhook stays Active"])
stateDiagram-v2
  [*] --> Pending : event queued
  Pending --> Sending : worker takes it
  Sending --> Delivered : endpoint answers 2xx
  Sending --> Pending : failed, waits for the next try
  Sending --> Failed : 8 attempts used
  Failed --> Pending : you press Send again
stateDiagram-v2
  [*] --> Active : webhook saved
  Active --> Inactive : you switch it off
  Inactive --> Active : you switch it on
  Active --> Disabled : 20 failures in a row
  Disabled --> Active : you fix it and switch it on

The body of a delivery - one shape for every event:

{
  "id": "<the event's id: deduplicate on it>",
  "event": "shipment.delivered",
  "version": 1,
  "occurred_at": "2026-11-20T05:00:00.000Z",
  "subject": {"type": "shipment", "id": 12, "code": "SHP-2611-0123"},
  "data": { ... your company's own view of the event ... }
}

Headers: Traincu-Event (the event name), Traincu-Delivery (the delivery id), Traincu-Signature, User-Agent: Traincu-Webhooks/1.0.

Events you can subscribe to (the list on the form is what is switched on for the platform):

Family Events
Shipments shipment.awarded, shipment.truck_assigned, shipment.status_changed, shipment.delivered, shipment.delayed, shipment.deviated, shipment.cancelled
Services service.requested, service.accepted, service.quote_accepted, service.completed, service_invoice.issued, service_invoice.paid
Parts orders parts_order.placed, parts_order.delivered, order_invoice.issued, order_invoice.paid
Insurance policy.activated, policy.expiring, policy.ended
Online store store_order.placed, store_order.paid, store_order.shipped
Accounting export.ready

Fields (webhook form) - Name (required), Endpoint URL (HTTPS, public, 500 characters at most, no user name or password in it), Description (optional), Events (at least one).

If something goes wrong - "The address must start with https://." / "The address points at a private, local or reserved network. Webhooks are sent only to public addresses." / "The host name could not be resolved." / "Choose at least one event." / "A company may hold at most 20 webhook endpoints." / "The endpoint is not active. Switch it on first." / in the log column Why: "The endpoint answered 500", "The endpoint could not be reached", "The address was refused (not a public HTTPS address)", "The webhook was switched off".

6.4 Check the signature of a webhook (for the developer)

Every delivery carries Traincu-Signature: t=<unix seconds>,v1=<signature>. The signature is the HMAC-SHA256 of the text "<t>.<raw body>" using your webhook secret, written in hexadecimal.

  1. Read the raw body exactly as it arrived (do not parse and re-write it).
  2. Read t and the v1 value(s) from the header.
  3. Refuse the call if t is older than your tolerance (5 minutes is usual).
  4. Compute the HMAC-SHA256 of t + "." + body with your secret and compare it with each v1 in constant time. During the 24 hours after a rotation the header carries two v1 values (new and old secret); accepting either is correct.
  5. Deduplicate on the event id of the body: a delivery can arrive more than once (a retry).
  6. Answer with a 2xx status quickly; do the work afterwards.
flowchart TD
  s1(["Your endpoint receives a POST"]) --> a1["Read the raw body and the Traincu-Signature header"]
  a1 --> d1{"Timestamp within 5 minutes?"}
  d1 -->|"No"| e1(["Refuse: too old"])
  d1 -->|"Yes"| a2["Compute HMAC-SHA256 of t dot body with your secret"]
  a2 --> d2{"Equal to any v1 value?"}
  d2 -->|"No"| e2(["Refuse: not from Traincu"])
  d2 -->|"Yes"| d3{"Event id already processed?"}
  d3 -->|"Yes"| e3(["Answer 200 and do nothing"])
  d3 -->|"No"| a3["Answer 200 at once, then process the event"]

6.5 Connect a GPS or tracking provider (C-16, Connections tab)

Purpose - bring the positions of trucks from the tracking provider you already use into Traincu's live tracking. Who - integrations.connections.

Steps

  1. Open the Connections tab. If Traincu has not switched the feeds on, a notice says so ("GPS feeds are not switched on by Traincu yet. You can add your provider account now; nothing is pulled from it until the feeds are switched on. Positions from the driver app keep arriving as usual.").
  2. Press Add connection. Fill Name, Format (today: Generic JSON, a positions list), the Credentials the provider gave you (API key, Provider address, Username, Password; stored encrypted and never shown again; leave a field blank on edit to keep it), tick Pull positions every minute and/or Accept positions the provider pushes.
  3. Under devices press Add device: type the provider's Device id and choose the Vehicle of your fleet it sits on (up to 500 devices; a truck that is not in your fleet is refused). Add the trucks first if your fleet is empty.
  4. Press Save connection. If the provider pushes, give it the push address and the token that Traincu support gave you (the page shows the address; a provider sends the token in the X-Hook-Token header or ?token=).
  5. Watch Status (Active, Paused, Error), Last pull, Last fix, Fixes stored. Pull now asks the provider at once. Pause and Resume stop and start it. Remove deletes the connection and its credentials (positions already stored stay).
  6. The page lists devices the provider reports that are not mapped to a vehicle: map them.
flowchart TD
  s1(["Open the Connections tab"]) --> a1["Press Add connection"]
  a1 --> a2["Name, format, provider credentials, pull and push choices"]
  a2 --> a3["Add each device id and choose its vehicle"]
  a3 --> a4["Press Save connection"]
  a4 --> d1{"Vehicles are yours and credentials saved?"}
  d1 -->|"No"| a5["Fix the message"] --> a3
  d1 -->|"Yes"| sys1[["Connection Active"]]
  sys1 --> d2{"Traincu switched GPS feeds on?"}
  d2 -->|"No"| e1(["Nothing is pulled yet. Driver app positions go on"])
  d2 -->|"Yes"| sys2[["Every minute: pull the positions or accept the push"]]
  sys2 --> sys3[["Fixes reach live tracking, oldest first"]]
  sys3 --> d3{"Provider answers?"}
  d3 -->|"No"| sys4[["Back-off 1, 5, 15, 60 min. After 3 failures Status is Error"]]
  d3 -->|"Yes"| e2(["Last fix and fixes stored grow"])

Good to know - a device that belongs to two companies is not fed to either (the page says it is ambiguous). A connection never shows its credentials after saving; use Edit and type new values to replace them.

If something goes wrong - "At most 500 devices can be mapped on one connection." / "Device X: the vehicle was not found in your fleet." / "GPS connection ... is paused. Resume it first." / provider reasons: "The provider refused the credentials." / "The provider's quota is used up." / "The provider took too long to answer." / "The provider answered in a form Traincu does not read." / "No credentials are saved."

6.6 Accounting feeds, mapping and the sync log (C-16, Accounting tab)

Purpose - let your accounting system read invoices, trips and costs, with your own account and tax codes on every line, and keep a log of what it read. Who - integrations.erp.

The three feeds

Feed Address Scope Main fields
Invoices GET /api/v1/public/exports/invoices invoices.export external_ref, number, document_type, issue_date, due_date, currency, customer, net, vat, total, paid, lines (each with account_code, tax_code, vat_rate), mapping_status
Trips GET /api/v1/public/exports/trips trips.export external_ref, status, date, cities, distance_km, customer, vehicle, shipment_code, invoice_external_ref, revenue, cost
Costs GET /api/v1/public/exports/costs costs.export external_ref, source, category, date, supplier, net, vat, total, vat_category, account_code, tax_code, mapping_status

How to pull - from and to are required (YYYY-MM-DD, both included, in the company's clock). A window is at most 93 days (currently set to 93; to be confirmed by the business). Add format=csv for the whole window in one file (up to 50,000 rows; bom=1 adds a byte-order mark so a spreadsheet opens Arabic text correctly), otherwise JSON is paged (limit up to 1,000, default 200, and cursor). Any other parameter is refused with a 422 that names it. Every row has an external_ref that never changes, so your system can upsert on it and a second pull of the same window gives the same references. Amounts are the document's own; Traincu never recomputes them.

Steps (screen)

  1. Open the Accounting tab. The table Accounting feeds shows each feed with its Scope, Status (Served or Not served yet, with who it waits for) and Last on the log.
  2. Choose a Feed, From and To and press Check: Traincu walks the window the way a pull would and lists the rows that have a problem; nothing is sent.
  3. Press Notify my system to send the export.ready webhook for that window to the webhooks that subscribed (once for the same data).
  4. Switch on Every morning, tell my webhooks which of yesterday's feeds hold rows if you want a daily notice (sent at about 02:30).
  5. Sync log: every pull, notice and check is one line: Time, Feed, How (Pulled by a key, Webhook notice, Checked here), Window, Format, Rows, With a problem, Result (Clean, With problems, Not served yet, Already announced, Failed), Times. Open a line to see its problem rows. The log holds counts, references and reasons, never an amount or a name. It is kept 180 days (currently set to 180; to be confirmed).
  6. Mapping (?section=mapping): press Add mapping. Fill Kind (Account or Tax code), Traincu key (for accounts sales:<kind> or sales:* for invoice lines, cost:<category> or cost:* for a cost; for tax codes vat_output:S (or Z, E, O) for a sale and vat_input:S for a cost), Your code (exactly as your system writes it) and a Note. Press Save. Once you map one code, every line you have not covered is listed in the sync log; a row is never dropped from a feed because of a mapping.
flowchart TD
  s1(["Open the Accounting tab"]) --> a1["Read the three feeds and their status"]
  a1 --> d1{"Feed served?"}
  d1 -->|"Not served yet"| e1(["Wait for the owning module to open it"])
  d1 -->|"Served"| a2["Choose From and To and press Check"]
  a2 --> sys1[["Walk the window. Nothing is sent. One log line"]]
  sys1 --> d2{"Rows with a problem?"}
  d2 -->|"Yes"| a3["Open the log line and read the problem rows"]
  a3 --> a4["Add the missing mapping"] --> a2
  d2 -->|"No"| a5["Press Notify my system"]
  a5 --> sys2[["export.ready webhook, once for the same data"]]
  sys2 --> o1[/"Your system pulls the feed with its key"/]
  o1 --> e2(["Rows upsert on external_ref"])
flowchart TD
  s1(["Accounting system pulls a feed with from and to"]) --> d1{"Key holds the feed scope?"}
  d1 -->|"No"| e1(["403 insufficient_scope"])
  d1 -->|"Yes"| d2{"from and to given, window short enough, no odd parameter?"}
  d2 -->|"No"| e2(["422 names the problem"])
  d2 -->|"Yes"| d3{"Format"}
  d3 -->|"JSON"| sys1[["A page of rows with meta next_cursor"]]
  d3 -->|"CSV"| sys2[["The whole window in one file"]]
  sys1 --> sys3[["Company codes put on rows, gaps flagged not dropped"]]
  sys2 --> sys3
  sys3 --> sys4[["One line added to the sync log"]]
  sys4 --> e3(["Your system upserts on external_ref"])

If something goes wrong - "The feed could not be read right now. Try again in a few minutes." / "X is not served for your company yet: no module has opened it." / "N rows, M with a problem. They are listed below." / "This window was announced before with the same data. Nothing was sent again." / "A window may not be longer than N days." / "A CSV file is the whole window in one answer: it takes no limit and no cursor."

6.7 The provider cards of Settings > Integrations (Traincu staff only)

Purpose - Traincu's own switchboard for the outside services the platform talks to. Who - Traincu staff whose staff role holds settings.integrations. A company does not see this page; you feel its effect.

Every card has a Mode: Off (the service is not used and the platform falls back), Test (made-up answers, no network, no cost; never allowed in production) and Live (the real provider; stays unavailable until the business has signed with the provider and the driver is finished). Changing a key or address asks for a recent password or code. Each real call is written to a ledger with its cost.

Card What it does for a company When off
Mail (SMTP) Sends e-mails (codes, invitations, reports) Mail goes to a log file
SMS gateway Sends texts Texts are written to a log
Wathq Fills the legal name from the CR number The owner types the company name
Nafath Identity check and sign-in with Nafath No Nafath check
Verification rules Restrict an activity when its licence ends; re-check the CR some days before it ends Staff decide by hand
Google Maps Finds addresses, distance and ETA The shipper types the distance
GPS / VTS feeds Decides whether the Connections tab pulls and pushes Positions come only from the driver app
Payment gateway (mada, card, Apple Pay, STC Pay) Card payments for invoices and bookings The customer gets a reference and pays by bank transfer; finance confirms it
ZATCA e-invoicing Clearance and reporting of invoices; companies connect their own device Companies cannot connect a device
flowchart TD
  s1(["Traincu staff open a provider card"]) --> a1["Choose the mode: Off, Test or Live"]
  a1 --> d1{"Mode"}
  d1 -->|"Off"| e1(["The feature falls back, for example bank transfer"])
  d1 -->|"Test"| d2{"Production environment?"}
  d2 -->|"Yes"| e2(["Refused: Test is never allowed in production"])
  d2 -->|"No"| e3(["Made-up answers, no network, no cost"])
  d1 -->|"Live"| d3{"Provider signed and the driver finished?"}
  d3 -->|"No"| e4(["Live cannot be chosen yet"])
  d3 -->|"Yes"| sys1[["Real calls go through the call ledger with their cost"]]

7. Screen by screen

C-16 - API and webhooks

Address /settings/integrations/keys (the Dev Pack address /app/developers is the same page), with the tabs /settings/integrations/webhooks, /settings/integrations/connections and /settings/integrations/accounting. Who integrations.keys, integrations.webhooks, integrations.connections, integrations.erp (Owner by default; the menu line is shown to whoever holds the keys permission). What you see a list per tab. API keys: Key, Type, Scopes, Created, Last used, Status, with the filters Type and Status (the Dev Pack's "Active, Inactive"; a third status Expired also exists). Webhooks: Name, Endpoint URL, Events, Status, Last delivery, Last answer, Failures in a row. What you can do New API key (the Dev Pack's "+ New API key"), Rotate, Revoke, Add webhook (the Dev Pack's "+ Add webhook"), Send test, deliveries log with Send again (HMAC-SHA256 signed, 6.3), plus the tabs the Dev Pack does not show: Connections (6.5) and Accounting (6.6). Excel and PDF export are on the lists.

Extra pages (no Dev Pack code)

Add and edit a webhook (settings.developers.webhooks.create, .edit)

A form with Name, Endpoint URL, Description and the Events (grouped by family). The events listed appear as the modules that raise them are switched on ("No event can be subscribed to yet" otherwise). Save returns to the webhook's page.

One webhook (settings.developers.webhooks.show)

Card The endpoint (status badge, URL, events, secret fingerprint, rotation date, last delivery, last answer, failures in a row, created), the box Checking a delivery (the headers and the signature rule), and the Deliveries table. Buttons: History, Send test, Edit, Back to list, Switch off or Switch on, Rotate secret, Delete. A red note says "Traincu switched this webhook off after 20 failed deliveries in a row. Check that the endpoint answers, then switch it on again." when it is Disabled.

Accounting pages (settings.developers.accounting...)

The tab (feeds table, check form, sync log, Mapping section), One line of the sync log (runs/{run}: time, how, rows, problem rows, result, times, digest, and the first rows with a problem), Add mapping and Edit mapping (Kind, Traincu key, Your code, Note), with Remove on a mapping.

Verification rules card (settings.integrations.verification)

Platform page for Traincu staff: Restrict an activity when its licence ends (every morning an approved activity whose licence has ended becomes restricted and opens again when staff verify the renewed licence) and Re-check the CR from (days before it ends) (asks Wathq again, at most once a week for each company, while Wathq is on). Button Save verification rules.

Provider card saves (Traincu staff)

settings.integrations.mail, .sms, .wathq, .nafath, .maps, .gps, .payments, .zatca save a card; .mail.test, .sms.test, .wathq.test, .nafath.test, .maps.test try it. See 6.7.

8. Tips and common questions

  1. I lost my API key. It cannot be shown again. Press Rotate on the key (a new secret, the old one stops at once) and copy the new one.
  2. A system suddenly gets 401. Check the status of the key: it may be Expired or Inactive (revoked). Make a new key.
  3. A system gets 403 insufficient_scope. The key does not hold the scope of that address. Make a new key with the scope; a key's scopes cannot be changed.
  4. A system gets 429. The key's calls a minute are used up. Wait the Retry-After seconds or ask for a higher limit when making the key (up to 1,000).
  5. Why does the API say 404 for a load I know exists? It may belong to another company or you may not be a party to it. The API never says "forbidden".
  6. My webhook shows Disabled. It failed 20 times in a row. Repair the endpoint (it must answer 2xx), press Send test, then Switch on.
  7. The same event arrived twice. A retry can repeat a delivery. Deduplicate on the id in the body.
  8. Can I test without touching real data? Make a Test key. A test webhook delivery (webhook.test) is sent with Send test.
  9. Why is my accounting feed "Not served yet"? The module that owns that data has not opened the feed for your company yet; nothing is wrong with your key.
  10. Where are GPS positions I pull? They go into live tracking like driver-app positions. Map each device to a truck or the fixes are not stored.
  11. Can I change data through the API? No. Version 1 only reads; writes (post a load, award, change a status) are planned and need a confirmed safe way to repeat a call.
  12. Who can see these tabs? The Owner, and any role that was given integrations.keys, integrations.webhooks, integrations.connections or integrations.erp in the Permission matrix.

9. Page reference (for support and testing)

Pages (every GET route of this guide):

Page Address Route name Who can open Described in
Accounting tab: feeds, sync log and mapping /settings/integrations/accounting settings.developers.accounting integrations.erp (Owner by default) 6.6 / 7 C-16
Add an accounting mapping /settings/integrations/accounting/mapping/create settings.developers.accounting.mapping.create integrations.erp 6.6 / 7 C-16
Edit an accounting mapping /settings/integrations/accounting/mapping/{mapping}/edit settings.developers.accounting.mapping.edit integrations.erp 6.6 / 7 C-16
One line of the sync log and its problem rows /settings/integrations/accounting/runs/{run} settings.developers.accounting.runs.show integrations.erp 6.6 / 7 C-16
Connections tab: GPS and tracking accounts /settings/integrations/connections settings.developers.connections integrations.connections (Owner by default) 6.5 / 7 C-16
API keys tab (C-16) /settings/integrations/keys settings.developers.keys integrations.keys (Owner by default) 6.1 / 7 C-16
Verification rules card (Traincu staff) /settings/integrations/verification settings.integrations.verification settings.integrations (Traincu staff only: platform permission) 6.7 / 7 Provider cards
Webhooks tab: the endpoints list /settings/integrations/webhooks settings.developers.webhooks integrations.webhooks (Owner by default) 6.3 / 7 C-16
Add a webhook /settings/integrations/webhooks/create settings.developers.webhooks.create integrations.webhooks 6.3 / 7 C-16
One webhook and its deliveries log /settings/integrations/webhooks/{webhook} settings.developers.webhooks.show integrations.webhooks 6.3 / 7 C-16
Edit a webhook /settings/integrations/webhooks/{webhook}/edit settings.developers.webhooks.edit integrations.webhooks 6.3 / 7 C-16

Actions (buttons and forms):

Action Route name Method and address Permission
Tell my webhooks a window is ready (export.ready) settings.developers.accounting.announce POST /settings/integrations/accounting/announce integrations.erp
Check a feed window (nothing is sent) settings.developers.accounting.check POST /settings/integrations/accounting/check integrations.erp
Switch the daily export notice on or off settings.developers.accounting.daily POST /settings/integrations/accounting/daily integrations.erp
Save a new mapping settings.developers.accounting.mapping.store POST /settings/integrations/accounting/mapping integrations.erp
Change a mapping settings.developers.accounting.mapping.update PUT /settings/integrations/accounting/mapping/{mapping} integrations.erp
Remove a mapping settings.developers.accounting.mapping.destroy DELETE /settings/integrations/accounting/mapping/{mapping} integrations.erp
Add a GPS connection settings.developers.connections.store POST /settings/integrations/connections integrations.connections
Change a GPS connection settings.developers.connections.update PUT /settings/integrations/connections/{account} integrations.connections
Remove a GPS connection settings.developers.connections.destroy DELETE /settings/integrations/connections/{account} integrations.connections
Pause a GPS connection settings.developers.connections.pause POST /settings/integrations/connections/{account}/pause integrations.connections
Pull positions now settings.developers.connections.pull POST /settings/integrations/connections/{account}/pull integrations.connections
Resume a GPS connection settings.developers.connections.resume POST /settings/integrations/connections/{account}/resume integrations.connections
Save the GPS feed switch (Traincu staff) settings.integrations.gps PUT /settings/integrations/gps settings.integrations (Traincu staff only)
Make a new API key settings.developers.keys.store POST /settings/integrations/keys integrations.keys
Revoke an API key settings.developers.keys.revoke POST /settings/integrations/keys/{client}/revoke integrations.keys
Rotate an API key (new secret) settings.developers.keys.rotate POST /settings/integrations/keys/{client}/rotate integrations.keys
Save the maps card (Traincu staff) settings.integrations.maps PUT /settings/integrations/maps settings.integrations (Traincu staff only)
Test the maps card (Traincu staff) settings.integrations.maps.test POST /settings/integrations/maps/test settings.integrations (Traincu staff only)
Save the Nafath card (Traincu staff) settings.integrations.nafath PUT /settings/integrations/nafath settings.integrations (Traincu staff only)
Try a Nafath request (Traincu staff) settings.integrations.nafath.test POST /settings/integrations/nafath/test settings.integrations (Traincu staff only)
Save the payment gateway card (Traincu staff) settings.integrations.payments PUT /settings/integrations/payments settings.integrations (Traincu staff only)
Save the verification rules (Traincu staff) settings.integrations.verification.update PUT /settings/integrations/verification settings.integrations (Traincu staff only)
Save the Wathq card (Traincu staff) settings.integrations.wathq PUT /settings/integrations/wathq settings.integrations (Traincu staff only)
Check a CR number through Wathq (Traincu staff) settings.integrations.wathq.test POST /settings/integrations/wathq/test settings.integrations (Traincu staff only)
Save a new webhook (the secret is shown once) settings.developers.webhooks.store POST /settings/integrations/webhooks integrations.webhooks
Change a webhook settings.developers.webhooks.update PUT /settings/integrations/webhooks/{webhook} integrations.webhooks
Delete a webhook and its deliveries log settings.developers.webhooks.destroy DELETE /settings/integrations/webhooks/{webhook} integrations.webhooks
Send one delivery again settings.developers.webhooks.deliveries.retry POST /settings/integrations/webhooks/{webhook}/deliveries/{delivery}/retry integrations.webhooks
Make a new webhook secret settings.developers.webhooks.rotate POST /settings/integrations/webhooks/{webhook}/rotate integrations.webhooks
Switch a webhook on or off settings.developers.webhooks.status POST /settings/integrations/webhooks/{webhook}/status integrations.webhooks
Send a test delivery settings.developers.webhooks.test POST /settings/integrations/webhooks/{webhook}/test integrations.webhooks
Save the ZATCA card (Traincu staff) settings.integrations.zatca PUT /settings/integrations/zatca settings.integrations (Traincu staff only)

Public API addresses (called by your systems with a key, under /api/v1/public):

What it answers Route name Method and address Scope
Traincu cargo types (filter active, hazardous) api.v1.public.cargo-types.index GET /api/v1/public/cargo-types loads.read
Active drivers and helpers of the company api.v1.public.drivers.index GET /api/v1/public/drivers drivers.read
Drivers free in a window api.v1.public.drivers.available GET /api/v1/public/drivers/available drivers.read
One driver api.v1.public.drivers.show GET /api/v1/public/drivers/{id} drivers.read
A driver papers and duty minutes left api.v1.public.drivers.compliance GET /api/v1/public/drivers/{id}/compliance drivers.read
Accounting feed: costs api.v1.public.exports.costs GET /api/v1/public/exports/costs costs.export
Accounting feed: invoices api.v1.public.exports.invoices GET /api/v1/public/exports/invoices invoices.export
Accounting feed: trips api.v1.public.exports.trips GET /api/v1/public/exports/trips trips.export
One load api.v1.public.loads.show GET /api/v1/public/loads/{code} loads.read
The company the key opens, scopes, limit, end date, server time api.v1.public.me GET /api/v1/public/me -
OpenAPI 3.1 description of this API api.v1.public.openapi GET /api/v1/public/openapi.json -
Shipments won as a carrier that still need a truck api.v1.public.shipments.awaiting-truck GET /api/v1/public/shipments/awaiting-truck shipments.read
One shipment api.v1.public.shipments.show GET /api/v1/public/shipments/{code} shipments.read
Status, ETA, stop stamps and last position of a shipment api.v1.public.shipments.track GET /api/v1/public/shipments/{code}/track shipments.read
Trucks free in a window api.v1.public.vehicles.available GET /api/v1/public/vehicles/available vehicles.read
One truck api.v1.public.vehicles.show GET /api/v1/public/vehicles/{id} vehicles.read
A truck papers and TGA verdict on a day api.v1.public.vehicles.compliance GET /api/v1/public/vehicles/{id}/compliance vehicles.read
Any other address or method: a problem answer api.v1.public.fallback `GET POST