Pereiti prie pagrindinio turinio

Developers

Outturn API

Push the records your systems already produce into Outturn, and read the findings Outturn detects. A new finding can also be delivered to your own endpoint as a signed webhook. Version 1.0.0.

Quick start

  1. In Outturn open Settings, Developers and create an API key. Choose what it may do: ingest:write to send records, findings:read to read findings. The key is shown once.
  2. Check the key works:
curl https://outturn.eu/api/public/v1/ping \
  -H "Authorization: Bearer $OUTTURN_API_KEY"

Then send a record. Every request that writes needs an Idempotency-Key:

curl -X POST https://outturn.eu/api/public/v1/records \
  -H "Authorization: Bearer $OUTTURN_API_KEY" \
  -H "Idempotency-Key: erp-2026-10-08-batch-1" \
  -H "Content-Type: application/json" \
  -d '{
    "record_type": "weighbridge_ticket",
    "records": [{
      "external_id": "WB-2026-000123",
      "ticket_no": "000123",
      "measured_at": "2026-10-08T07:30:00+03:00",
      "gross_kg": "41250",
      "tare_kg": "15310",
      "net_kg": "25940",
      "tractor_plate": "ABC123"
    }]
  }'
{
  "request_id": "5d0a6c1e-2f0e-4c58-9a57-0d6a5e4f2b11",
  "record_type": "weighbridge_ticket",
  "accepted": 1,
  "facts_written": { "measurements": 3 },
  "note": "Records are in the ledger. Checks run within about two minutes and new findings are delivered to your webhook endpoints."
}

Prefer Python?

import os
import uuid

import requests

response = requests.post(
    "https://outturn.eu/api/public/v1/records",
    headers={
        "Authorization": f"Bearer {os.environ['OUTTURN_API_KEY']}",
        "Idempotency-Key": "erp-2026-10-08-batch-1",  # reuse the SAME key when you retry
    },
    json={"record_type": "weighbridge_ticket", "records": [{"external_id": "WB-1", "ticket_no": "1",
          "measured_at": "2026-10-08T07:30:00+03:00", "net_kg": "25940"}]},
    timeout=30,
)
response.raise_for_status()

Authentication

Every call carries Authorization: Bearer otk_.... Keys belong to one workspace: a key can only ever read or write that workspace's data. Keep it on your server; never put it in a browser or a mobile app. A wrong, revoked or expired key always gets the same 401. Rotate a key from Settings; the old key can stay valid for a grace period (default 24 hours) so you can deploy the new one without a gap.

Sending records

  • One record type per request, up to 500 records and 2 MB. Every record has your own external_id.
  • Checked before anything is written. If any record is invalid the whole request is refused with 422 and a list of every problem; nothing is stored. Timestamps need a UTC offset (2026-10-08T07:30:00+03:00), numbers are exact decimals, unknown fields are refused.
  • Retries are safe. Repeat a request with the same Idempotency-Key and body and you get the first answer back (header Idempotent-Replayed: true). Keys are remembered for 30 days. The same key with a different body is 409. Independently, sending the same external_id again never duplicates a fact.
  • Corrections. To change a record you sent earlier, send it again with correction_reason. The earlier version is kept and superseded, never overwritten, so the history stays provable.
  • Checks run for you. Within about two minutes the deterministic checks run on the new data; findings appear in Outturn and are pushed to your webhooks.

A rejected batch looks like this:

{
  "error": { "code": "validation_failed", "message": "2 problem(s) found; nothing was written" },
  "errors": [
    { "index": 0, "external_id": "WB-1", "field": "measured_at", "code": "invalid_timestamp",
      "message": "measured_at must be an RFC 3339 timestamp with a UTC offset, e.g. 2026-10-08T07:30:00+03:00" },
    { "index": 3, "external_id": "WB-4", "field": null, "code": "missing_one_of",
      "message": "at least one of gross_kg, tare_kg, net_kg is required" }
  ],
  "errors_truncated": false
}

Record types

Each type maps to the same ledger tables as a file upload, with provenance "API" and your key's name in the audit trail.

Weighbridge ticket weighbridge_ticket

One weighing ticket. Send the gross, tare and/or net weight you have. At least one of: gross_kg, tare_kg, net_kg.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
ticket_nostringyesTicket number as printed by the scale software.
measured_atstring (date-time)yesWhen the weighing happened (RFC 3339, with offset).
gross_kgnumber or stringGross weight in kilograms.
tare_kgnumber or stringTare weight in kilograms.
net_kgnumber or stringNet weight in kilograms.
tractor_platestringTractor plate as read at the gate.
trailer_platestringTrailer plate.
lot_codestringCargo lot the weighing belongs to.
booking_nostringBooking or order number.
instrumentstringScale identifier.
contractual_statusstringCONTRACTUAL if this is the terminal's billing weight, otherwise INFORMATION_ONLY. One of: CONTRACTUAL, INFORMATION_ONLY.
{
  "external_id": "WB-2026-000123",
  "ticket_no": "000123",
  "measured_at": "2026-10-08T07:30:00+03:00",
  "gross_kg": "41250",
  "tare_kg": "15310",
  "net_kg": "25940",
  "tractor_plate": "ABC123",
  "lot_code": "LOT-WHEAT-0007"
}

Wagon visit wagon_visit

One wagon on a train: identity, arrival and the rail-desk milestones.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
wagon_nostringyes12-digit UIC (check digit validated) or 8-digit 1520 wagon number.
train_refstringTrain number or reference.
consignment_note_nostringConsignment note (CIM/SMGS) number.
lot_codestringCargo lot carried.
arrived_atstring (date-time)Arrival at the terminal.
departed_atstring (date-time)Departure.
placement_atstring (date-time)Placement of the train at the loading/unloading track.
acceptance_atstring (date-time)Acceptance of the train by the terminal.
completed_atstring (date-time)Completion of loading or unloading.
documents_handed_over_atstring (date-time)Documents handed over to the carrier.
waybill_mass_kgnumber or stringMass declared on the waybill, kilograms.
{
  "external_id": "WAGON-2026-10-08-0001",
  "wagon_no": "315600270120",
  "train_ref": "T-4412",
  "arrived_at": "2026-10-08T05:10:00+03:00",
  "placement_at": "2026-10-08T06:00:00+03:00"
}

Truck visit truck_visit

One truck passing the gate.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
booking_nostringBooking or order number.
tractor_platestringTractor plate.
trailer_platestringTrailer plate.
cmr_nostringCMR number.
lot_codestringCargo lot.
arrived_atstring (date-time)Gate-in time.
departed_atstring (date-time)Gate-out time.
{
  "external_id": "GATE-2026-10-08-0042",
  "booking_no": "BK-77123",
  "tractor_plate": "ABC123",
  "arrived_at": "2026-10-08T07:05:00+03:00"
}

Vessel call vessel_call

One vessel call with its operational timestamps.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
imostringyesIMO number (7 digits, check digit validated).
vessel_namestringyesVessel name.
call_refstringYour port-call reference.
voyage_nostringVoyage number.
berthstringBerth code.
lot_codestringCargo lot discharged or loaded.
eta_atstring (date-time)Estimated arrival.
ata_atstring (date-time)Actual arrival.
nor_tendered_atstring (date-time)Notice of readiness tendered.
all_fast_atstring (date-time)All fast.
discharge_completed_atstring (date-time)Discharge completed.
loading_completed_atstring (date-time)Loading completed.
planned_sailing_atstring (date-time)Planned sailing.
sailing_atstring (date-time)Actual sailing.
{
  "external_id": "CALL-2026-0921",
  "imo": "9074729",
  "vessel_name": "MV EXAMPLE",
  "call_ref": "KLP-2026-0921-VC07",
  "ata_at": "2026-10-08T04:20:00+03:00"
}

Stock movement stock_movement

One receipt into or issue out of stock for a cargo lot. At least one of: receipt_t, issue_t, receipt_kg, issue_kg.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
lot_codestringyesCargo lot.
moved_atstring (date-time)yesWhen the movement happened.
receipt_tnumber or stringReceived, tonnes.
issue_tnumber or stringIssued, tonnes.
receipt_kgnumber or stringReceived, kilograms.
issue_kgnumber or stringIssued, kilograms.
location_codestringStorage location.
reasonstringReason or document reference.
{
  "external_id": "STK-2026-10-08-0007",
  "lot_code": "LOT-WHEAT-0007",
  "moved_at": "2026-10-08T09:00:00+03:00",
  "issue_t": "25.94",
  "location_code": "SILO-3"
}

Invoice line invoice_line

One line of an issued invoice, already billed.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
service_codestringyesService code of the line (e.g. storage, handling).
amountnumber or stringyesLine amount.
invoice_datestring (date)yesInvoice date (YYYY-MM-DD).
invoice_refstringInvoice number.
quantitynumber or stringQuantity billed.
unitstringUnit of the quantity.
ratenumber or stringRate per unit.
currencystringISO 4217 currency code (default EUR).
referencestringVessel call, wagon or booking the line bills for.
lot_codestringCargo lot.
payer_codestringPayer party code.
{
  "external_id": "INV-2026-0451-L2",
  "service_code": "storage",
  "amount": "1840.50",
  "invoice_date": "2026-10-08",
  "invoice_ref": "INV-2026-0451",
  "currency": "EUR",
  "reference": "KLP-2026-0921-VC07"
}

Carrier statement line carrier_statement_line

One line of a railway carrier's wagon-use or storage statement.

FieldTypeRequiredMeaning
external_idstringyesYour own unique id for this record.
wagon_nostringyesWagon number (12-digit UIC or 8-digit 1520).
service_codestringyeswagon-use or storage-organisation.
billed_qtynumber or stringHours or days billed.
rate_eurnumber or stringRate in EUR.
amount_eurnumber or stringLine amount in EUR.
period_startstring (date)Start of the billed period.
period_endstring (date)End of the billed period.
invoice_nostringStatement or invoice number.
line_nostringLine number on the statement.
stationstringStation.
{
  "external_id": "LTG-2026-10-L0001",
  "wagon_no": "315600270120",
  "service_code": "wagon-use",
  "billed_qty": "36",
  "rate_eur": "1.15",
  "amount_eur": "41.40"
}

Reading findings

GET /findings returns the findings of your workspace, oldest detection first, with next_cursor for paging. Filter with status, severity, department and detected_since. Each finding carries the rule, the inputs, the tolerance and the money at stake, so you can show the proof next to it.

curl "https://outturn.eu/api/public/v1/findings?severity=HIGH&limit=50" \
  -H "Authorization: Bearer $OUTTURN_API_KEY"

Webhooks

Add an HTTPS endpoint in Settings, Developers. Each new finding is sent once as a POST with a JSON body. The signing secret (whsec_...) is shown once when you add the endpoint.

{
  "id": "evt_9b1c0f2e7d4a4c11a5d3c2b1f0e9d8c7",
  "type": "finding.created",
  "api_version": "v1",
  "created_at": "2026-10-08T07:41:12+00:00",
  "data": {
    "id": "0b9f7a42-1c5e-4f0b-8d86-4d3a7e5c9a10",
    "rule_id": "RAIL-01",
    "title": "Wagon use charged beyond free time",
    "severity": "HIGH",
    "department": "RAIL",
    "money_at_stake": { "amount": "1840.50", "currency": "EUR" },
    "explanation": "...",
    "url": "https://outturn.eu/findings/0b9f7a42-1c5e-4f0b-8d86-4d3a7e5c9a10"
  }
}
  • Verify the signature. Outturn-Signature: t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256 of "<t>." + raw body with your secret. Compare in constant time and reject a t older than five minutes: that is your replay protection.
  • Answer with any 2xx within 10 seconds. Anything else is retried after 1 minute, 5 minutes, 30 minutes, 2, 6, 12 and 24 hours (eight attempts), then marked as given up. Redirects are not followed.
  • De-duplicate on id. It is the same on every retry and on a manual replay. Headers Outturn-Event-Id, Outturn-Delivery-Id and Outturn-Delivery-Attempt help with logging.
  • Delivery log and replay. Settings shows every delivery with its result; Replay sends an event again at any time.

Verification, Node.js:

import { createHmac, timingSafeEqual } from "node:crypto";

export function verifyOutturnSignature(secret, header, rawBody, toleranceSeconds = 300) {
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
  const t = Number(parts.t);
  if (!Number.isFinite(t) || Math.abs(Date.now() / 1000 - t) > toleranceSeconds) return false;
  const expected = createHmac("sha256", secret).update(`${t}.`).update(rawBody).digest();
  const given = Buffer.from(parts.v1 ?? "", "hex");
  return given.length === expected.length && timingSafeEqual(given, expected);
}

// Express: use express.raw({ type: "application/json" }) so rawBody is the exact bytes received.
// if (!verifyOutturnSignature(process.env.OUTTURN_WEBHOOK_SECRET, req.get("Outturn-Signature") ?? "", req.body)) return res.sendStatus(400);

Verification, Python:

import hashlib
import hmac
import time


def verify_outturn_signature(secret: str, header: str, raw_body: bytes, tolerance: int = 300) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
    try:
        t = int(parts["t"])
    except (KeyError, ValueError):
        return False
    if abs(time.time() - t) > tolerance:
        return False
    expected = hmac.new(secret.encode(), f"{t}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, parts.get("v1", ""))

Limits and errors

  • Rate limit per key (default 120 requests per minute, set when you create the key). Every response carries X-RateLimit-Limit and X-RateLimit-Remaining; 429 comes with Retry-After.
  • Errors are always {"error": {"code": "...", "message": "..."}}. Codes you may meet: unauthorized, forbidden, rate_limited, validation_failed, idempotency_key_reused, workspace_read_only, plan_does_not_include_api.
  • Versioning: the version is in the path (/api/public/v1). Additive changes (new fields, new record types) do not change the version; anything else would be a new version announced here first.
  • Every key and webhook action is written to your workspace's audit trail. Keys are stored only as a one-way fingerprint.

Endpoint reference

Base URL https://outturn.eu/api/public/v1. The machine-readable description is the OpenAPI file above.

get/ping

Check your key

Returns the workspace and the scopes of the key you are calling with.

get/record-types

List the record types you can send

post/records

Send records (idempotent)

Send a batch of records of one documented type. The whole batch is checked first: if any record is invalid the response is 422 with every problem and nothing is written.

  • Idempotency-Key (header) Required. 1-128 characters from A-Z a-z 0-9 . _ : -. A retry with the same key and body returns the first response.

get/findings

List findings

Findings of your workspace, oldest detection first. Page with ``next_cursor``.

  • status (query) One of OPEN, ACKNOWLEDGED, RESOLVED, DISMISSED, CHECKED_OK.
  • severity (query) One of INFO, LOW, MEDIUM, HIGH, CRITICAL.
  • department (query) One of VESSEL, GATE, WEIGHBRIDGE, RAIL, WAREHOUSE, LAB, CUSTOMS, COMMERCIAL, FINANCE, HSE, MANAGEMENT.
  • detected_since (query) Only findings detected at or after this instant (RFC 3339).
  • cursor (query) Opaque value from next_cursor.
  • limit (query)

get/findings/{finding_id}

Get one finding

  • finding_id (path, required)