Administration and integrations

API and webhooks

An administrator issues API keys that let a script read Logley’s records, and registers webhooks that post signed events to a URL of your own. Together they drive systems with no built-in connector, read-only for now: a key cannot upload or change anything.

ABOUT 12 MINUTESTUTORIALFOR DEVELOPERS AND IT

Goal

Issue a key, make one authenticated call, and receive an event from a webhook.

What a key opens, and what it does not

An API key authenticates Logley’s agent tool interface: a small, self-describing set of tools under /api/agent/, the same one AI agents use. Every call is checked against the key’s scopes, confined to the key’s organization, and recorded.

A key can
  • List the tools its scopes allow, each with its input schema.
  • Read documents, invoices, shipments, suppliers, contracts, routes, rate cards and alerts, and search the text of your documents.
  • Be held to a per-minute call limit you set (or none), and be revoked at once.
A key cannot
  • Upload a document, or change or approve anything — write tools are not enabled yet.
  • Download an original file.
  • Call the rest of the REST API, webhooks included. The web interface uses that with a signed-in session.

Where is the endpoint reference? There is no endpoint reference to browse on an installed system: the Swagger page is switched on only when the server runs in development mode. The reference is the manifest a key receives from GET /api/agent/tools, which describes every tool that key may call.

Before you begin

  • The Admin role — only administrators create API keys and webhooks
  • A calling system that reaches your Logley address over HTTPS and trusts its certificate
  • For webhooks, a receiver of your own at an https:// address. One on your own network has to be allowed under Settings → Integrations → Internal hosts first

An installation that uses its own private certificate authority serves the CA certificate at /setup/ca.crt, for the calling system to trust.

Create a key

  1. Open API keys

    Press New key. A dialog opens.

    Settings, then Integrations, then API keys

  2. Describe the key

    • Key name — required. The key appears under this name in the list and in the audit trail.
    • Kind — Integration for a script or connector, AI agent for an MCP client. The kind is a label: either kind reaches the same tools, and the audit trail records every key under its name. Agents are covered under Settings → Integrations → AI agents.
    • Scopes — at least one is required. Each has a line saying what it allows today. Tick only what the job needs; the table below shows the tools each one opens.
    • Rate limit — requests per minute, counted per clock minute. Left empty, there is no limit; past it, requests get HTTP 429 with a Retry-After of 60 seconds.
    New key opens this dialog. There is no expiry field.
  3. Create, and copy the key at once

    Press Create key. The dialog closes and the key, which begins lb_, is shown once at the top of the tab, under Copy this key now — it won't be shown again., with a copy button. Copy it before you press Dismiss or leave the tab. Logley keeps only a SHA-256 hash of it, so a lost key cannot be recovered: revoke it and create another.

    The only moment the whole key is on screen. Once dismissed, the list shows just its first characters.
  4. Watch and revoke

    The table shows each key’s name with its kind, its first characters, its scopes, when it was Last used and its Limit. Revoke asks first, naming the key and saying that a revoked key cannot be restored. The next request made with it is refused, and it stays in the list as revoked, with when and by whom. Its creation, first use, revocation and refused calls are in the audit log, under the entity type API key.

No expiry

The dialog sets no expiry, so a key works until it is revoked. Revoke the keys you no longer use — their last-used date shows which they are.

What each scope opens:

API key scopes and the tools they open
ScopeTools it opens
documents.readsearch_documents, query_documents, search_knowledge, get_document, get_dashboard_summary
invoices.readlist_invoices, query_invoices, get_invoice, get_reconciliation_report
shipments.readlist_shipments, query_shipments, get_shipment
suppliers.readlist_suppliers, query_suppliers, get_supplier, list_rate_cards, query_rate_cards
alerts.readlist_alerts, query_alerts
contracts.readquery_contracts, get_contract
reports.readquery_routes, run_report
billing.readquery_sell_rates
documents.write, invoices.editNothing yet — there are no write tools.

A query_ tool counts and totals every matching record on the server, and can group them; a list_ tool returns rows, up to its limit. The shipment, route and rate-card tools follow the organization’s pages: where Shipments, Routes or Rate cards is not part of the product, the manifest leaves its tools out and a call to one is refused.

Authenticate a request

Send the key in the X-Api-Key header on every request. A key sent as Authorization: Bearer is not accepted: that header is read as a signed-in session’s token, and refused.

# What may this key do? The manifest lists its tools, each with an input schema.
curl https://<your-logley-address>/api/agent/tools \
  -H "X-Api-Key: <your API key>"

# Call one tool: here, one invoice by its document id.
curl https://<your-logley-address>/api/agent/invoke \
  -H "X-Api-Key: <your API key>" \
  -H "Content-Type: application/json" \
  -d '{"tool": "get_invoice", "args": {"invoiceId": "<document id>"}}'

Every answer to invoke has the same shape, { status, data, error, actionId }. status is ok with the data, or error with a code such as permission_denied, not_found or validation_failed and a readable message — both as HTTP 200, because the call itself was understood. A missing or unknown key gets HTTP 401. actionId names the recorded call, which GET /api/agent/actions/{id} returns.

Register a webhook

  1. Open Webhooks

    Press Add webhook. A dialog opens. Its button stores the webhook at once: nothing else on the page needs saving.

    Settings, then Integrations, then Webhooks

  2. Enter the address and pick the events

    • The Address must start with http:// or https:// and resolve to a public IP address, or to a private one allowed for your organization. An administrator adds that on Settings → Integrations → Internal hosts: each change is saved at once, needs no restart and applies to your organization’s integrations only. Loopback, link-local and metadata addresses are never allowed, even when listed. The address is checked when you create the webhook and again before every delivery. Use https — otherwise the payload can be read on the way.
    • Events to subscribe to offers nine events by name; the table further down gives the code each one is sent under, and so does the Guide tab. Pick at least one event; Logley refuses a webhook with none.
    • Active is ticked: Logley delivers events to the webhook from the moment it is added. Untick it to add the webhook switched off.
    • If the webhook is refused (for an internal address, for instance), the dialog stays open and shows the server’s reason, such as that the host resolves to a non-public address, with the entry to add under Settings → Integrations → Internal hosts. Failed to create webhook appears only when the server gives none.
    The nine events the dialog offers, none ticked yet. Logley makes the signing secret itself, and shows it once the webhook is added.
  3. Press Add webhook, and copy the signing secret

    The dialog closes and the webhook’s signing secret is shown once at the top of the tab, under Copy the signing secret now: it is not shown again., with a copy button. Copy it before you press Dismiss or leave the tab: your receiver needs it to check each delivery. The webhook is a row in the table: its Address, its Events, its Last delivery, a switch under Active that turns it on or off at once, Test, which sends that webhook a test event, a pencil that opens the dialog again to change the address, the events or Active, and a bin that deletes the webhook after asking. Last delivery says how the newest attempt went and when; select it to open Recent deliveries under the row: the last 20 attempts, each marked Delivered or Failed, with the event, the HTTP status and the time.

    One webhook with its deliveries open. The one marked Failed is a delivery the receiver answered with 503 — it is retried on the schedule below.
Check a new webhook with Test

Press Test in the webhook’s row. Logley queues a webhook.test event for that webhook alone, whatever events it subscribes to, and sends it within about a minute, signed like any other delivery. It is listed under Recent deliveries with the status your receiver answered.

The events

Names are exactly as Logley sends them, and every payload wraps its data in the same envelope: eventType, occurredAt, organizationId. The first nine can be ticked in the dialog. The next five — and *, for every event — need a subscription made through the webhook endpoints, POST /api/webhooks. The last, webhook.test, needs none: Test sends it to the webhook it is pressed on.

No event is sent about a private document. A webhook gets what an API key could read back, and a key cannot read a private document. Logley checks as each event happens, so making a document private stops the events that follow but cannot recall one already sent.

Webhook events, when each is sent and what its data carries
EventSent whendata carries
document.readyProcessing finishes and the document is ready. Not sent for a private document.documentId, filename, documentType, status
document.needs_reviewProcessing finishes and the document needs a person. Not sent for a private document.documentId, filename, documentType, status
invoice.auto_approvedThe auto-approval check approves an invoice. Not sent for a private document.documentId, status, approvalNote
invoice.pending_approvalThe auto-approval check holds an invoice for a person to approve. Not sent for a private document.documentId, status, approvalNote
invoice.approvedA person approves an invoice. Not sent for a private document.documentId, filename, status
invoice.rejectedA person rejects an invoice. Not sent for a private document.documentId, filename, reason, category
alert.createdAn alert is raised, unless it is addressed to one person or is about a private document.alertId, alertType, severity, title, description, relatedDocumentId, createdAt
shipment.completeA document is matched to a shipment that then has its CMR, its invoice and its proof of delivery linked.shipmentId, shipmentNumber
shipment.cancelledA person marks a shipment cancelled.shipmentId, shipmentNumber, cancelledAt, note
invoice.on_holdThe auto-approval check puts an invoice on hold because it does not match its order. Not sent for a private document.documentId, status, approvalNote
invoice.changes_requestedA person requests changes to an invoice. Not sent for a private document.documentId, filename, note, assigneeUserId
invoice.resubmittedA person resubmits an invoice after changes were requested. Not sent for a private document.documentId, filename
invoice.issuedA draft is issued in Billing.invoiceId, number, series, documentType, customerId, shipmentId, currency, netAmount, vatAmount, grossAmount, issueDate, dueDate
shipment.tracking.position_updatedA driver’s device reports a position.shipmentId, latitude, longitude, accuracyM, occurredAt
webhook.testTest is pressed on a webhook. Sent to that webhook only.message

Check what arrives

Each delivery is an HTTP POST with a JSON body and two headers: X-Logley-Event, the event name, and X-Logley-Signature, sha256= followed by a hex HMAC-SHA256 of the body.

POST <your webhook URL>
Content-Type: application/json; charset=utf-8
X-Logley-Event: invoice.approved
X-Logley-Signature: sha256=<64 hex characters>

{"eventType":"invoice.approved","occurredAt":"<UTC time>","organizationId":"<id>","data":{"documentId":"<id>","filename":"<file name>","status":"approved"}}

To check the signature, compute it yourself over the raw body, before you parse it, and compare. Use the secret exactly as the text you were given; it is not base64-decoded first.

expected = "sha256=" + lowercase_hex(HMAC_SHA256(key = UTF8(secret), message = raw_request_body))
valid    = constant_time_equals(expected, header("X-Logley-Signature"))
Where the secret comes from

Logley generates a secret for each webhook and shows it once, at the top of the Webhooks tab, when you add the webhook. Copy it then. Changing the webhook in its dialog keeps the secret; if it is lost, delete the webhook and add it again for a new one. A webhook created through POST /api/webhooks can carry a secret of your own in the request, and PUT /api/webhooks/{id} replaces one. Both are requests made as a signed-in administrator — an API key cannot manage webhooks.

  • A background job sends waiting deliveries every minute.
  • An answer in the 2xx range within 10 seconds counts as delivered. Anything else is retried after 30 seconds, 2 minutes, 10 minutes and 1 hour — five attempts in all by default (Webhooks:MaxAttempts and Webhooks:TimeoutSeconds in the server configuration).
  • When the ten most recent deliveries to a webhook have all failed, Logley switches it off. Switch it back on once the receiver is fixed.
  • A delivery carries no id of its own, and one answered too slowly is sent again even if you processed it — so the same event can arrive twice. Make the receiver idempotent, keyed on the record id in data.

Driving a system that has no connector

  1. Subscribe

    Register a webhook for the event that matters, pointing at a receiver you run.

  2. Read the record back

    On each delivery, take the id from data and fetch the full record with your key: get_invoice with the documentId as its invoiceId, get_document for any other document, get_shipment for a shipment.

  3. Write it where it belongs

    Put what you read into the other system. Reading the record back, rather than trusting the payload, means your system acts only on what Logley itself returns.

If the system that needs the data sits inside your network, have the server’s administrator allow its host first, or poll instead: run the list tools on a schedule (for instance, list_invoices filtered by status).

Zapier and Make, which Settings → Integrations → Guide describes, fit the same pattern. Their webhook addresses are public, so Logley can deliver to them. But their HTTP step calls Logley from their cloud, so it works only if your installation is reachable from the internet. The key goes in X-Api-Key, not in a Bearer header. For the systems Logley does connect to directly, see the supported sources and their status.

NEXT GUIDEInfrastructure requirements
Continue

Continue exploring

Was this guide useful?

If something was missing or unclear, the contact page says where to write.

Contact