API

Ingest and decide HTTP endpoints.

Authenticate ingest with a project API key: Authorization: Bearer hitly_...

The key must belong to HITLY_PROJECT_ID. Send Idempotency-Key when the origin may retry the suspend POST.

Create-once

Within a project, a repeat POST with the same Idempotency-Key from the API key that created the request returns the existing request instead of creating a second ask ("replayed": true, same id, stored request unchanged) only when the new body's payloadHash matches the stored request. payloadHash is b64url(SHA-256(JCS(envelope))) of the ingested create-once record (plugin.ingest() output stored on approvals.envelope; RFC 8785 JSON Canonicalization, unpadded base64url). Replay applies when:

  • the existing request is still open (pending or failed_resume), at any age; or
  • it is closed (decided, rejected, cancelled or expired) and was created less than the create-once retention period ago.

payloadHash includes every field the plugin wrote onto that record: action (name + args), allowedActions, gating/context (reasonRequired, contextMarkdown, metadata, externalUrls, attachments), resumeSchema, expiresAt, editableFields, editReason, envelope evidence fields (traceId, spanId, agentId, systemId, inventoryId, policyId, policyRationale, riskTier, toolName, sensitivity, dataCategories), and the nested origin (plugin, projectId, runId, stepId, resumeHandle including origin URLs merged from the project such as mastraBaseUrl, details, and origin evidence fields). JSON member order is canonicalised, so shuffled action.args keys still match.

payloadHash excludes HTTP headers (Authorization, Idempotency-Key, Content-Type, x-hitly-client), API key material, host-assigned create-once fields (id, status, timestamps, requesterKeyId, replayed, createOnce, response argsHash), project credential secrets (resumeSecret, token) which are not copied onto the envelope, unmapped extra keys on the raw POST body (dropped at ingest), and undefined keys (dropped so ingest/JSONB match the stored row).

If the same key reuses the Idempotency-Key with a different payloadHash, the POST is rejected with 409 and { "error": "…", "code": "idempotency_conflict" }. The stored response is not replayed and no second row is created, so a bot cannot treat a changed body as recorded. The project log line for that conflict includes approvalId and does not log the request payload or secrets. To re-ask with a revised payload, send a new Idempotency-Key (hitl-spec 4.2: a re-submit is a new requestId).

Replay is per API key (consistent with key-scoped cancel and the pending list): a sibling key on the same project never replays another key's request. While the Idempotency-Key is still held by a request the calling key cannot replay (a sibling's, still open or inside the retention window), that POST is rejected with 409 and { "error": … } only - no id, status or payload of the other request is disclosed. During the 10-day idempotency window (the boundary instant is exclusive), a legacy row with no requester key returns 409 for any key. An open legacy row with no requester key returns 409 at any age.

The retention period is 10 days by default and is published in every create response as createOnce.retentionSeconds. Self-hosted operators can change it with HITLY_CREATE_ONCE_RETENTION_DAYS (whole days, 1–3650). After the period, a repeat POST of the same Idempotency-Key may create a new request. Keep your own record of a spent requestId at least that long.

Rate limiting

Every /api/v1 route counts into the shared Postgres limiter, so budgets hold across replicas; over-budget answers are 429 with a Retry-After header in seconds. Limits are per API key (hashed — the key itself is never stored) on the key-authed surface: 120/min for the create POST, 600/min for reads (GET /api/v1/approvals, by-run-id), 120/min for requester cancel. Session-authed routes count 600/min per signed-in user; unauthenticated health and signup-status count 600/min per client address; invite lookup/accept count 30/min per invite token. Operators tune every family through HITLY_RATE_LIMIT_* env vars — see Self-host → Rate limiting. Clients should honor Retry-After before retrying.

Create approval

POST /api/v1/approvals

{
  "plugin": "mastra",
  "projectId": "prj_...",
  "kind": "workflow",
  "workflowId": "refund-workflow",
  "runId": "run_...",
  "stepId": "hitly-approval",
  "action": { "name": "send-refund", "args": { "orderId": "1842" } },
  "suspendPayload": { "reason": "Human approval required." },

  // Evidence fields (all optional)
  "traceId": "trace_...",
  "spanId": "span_...",
  "agentId": "refund-agent",
  "systemId": "refund-agent-prod",
  "inventoryId": "ai-inv-refund-agent-v2",
  "policyId": "refund-over-100",
  "policyRationale": "Refunds over $100 require approval",
  "riskTier": "medium",
  "toolName": "send_refund"
}

A paused project refuses new ingest with 409 and { "error": "project paused", "code": "project_paused" }. An archived project refuses ingest (and reviewer decide/cancel) with 409 and { "error": "project archived", "code": "project_archived" }. Replay of an existing create-once row is not a new request. See Projects.

mastraBaseUrl is optional when the project already stores the origin base URL.

Evidence fields are optional; HITLy persists them when present and writes them to the configured HTTP evidence sink. See Envelope for field descriptions.

HTTP origins send plugin: "http", resumeUrl, and optional metadata. HITLy echoes metadata on the resume POST:

{
  "plugin": "http",
  "projectId": "prj_...",
  "runId": "execution-or-page-id",
  "actionName": "http-callback",
  "metadata": { "pageId": "…" },
  "resumeUrl": "https://your-callback.example/hitly-resume"
}

The create response is { id, status, replayed, envelope, argsHash, createOnce }. argsHash is b64url(SHA-256(JCS(action.args))) over the original arguments (RFC 8785 JSON Canonicalization, unpadded base64url), the same value a hitl/response/v0 carries.

On accept or reject, HITLy POSTs that metadata unchanged to resumeUrl:

{
  "decision": "accept",
  "id": "apr_...",
  "metadata": { "pageId": "…" }
}

Decide

POST /api/v1/approvals/:id/decide (session cookie)

{ "decision": "accept" }

or { "decision": "edit", "editedArgs": { "amount": 2000 } }.

The JSON response includes resumeResponse: the payload sent to the origin (resumeData) plus the origin HTTP status and body. For Mastra workflows that body is the completed run result.

Retry resume

POST /api/v1/approvals/:id/retry-resume when status is failed_resume.

Force cancel

POST /api/v1/approvals/:id/cancel (reviewer session) when status is pending or failed_resume. Closes the item as cancelled without calling the origin. Use when the origin run is no longer suspended.

Inbox

GET /api/v1/inbox (session cookie or Authorization: Bearer <session token>)

Query: scope=all|open|closed, q, projectId, limit (1–200, default 100), cursor (opaque; pass the previous page's nextCursor). open is the pending inbox: items still awaiting a human (pending). A human-decided failed_resume row has an outcome already, so it appears only under all. closed is decided + expired + cancelled. Newest first (created_at DESC, id DESC). A page that has more rows returns nextCursor; the last page returns nextCursor: null. Invalid cursor is 400.

GET /api/v1/inbox/summary returns { pending, failedResume, decidedToday, projectCount }.

GET /api/v1/approvals/:id (session cookie or reviewer Bearer token) returns envelope, origin, originFields, decisions, canAct, top-level answerSchema (the stored ask_user schema, or null when the request has none), top-level answer (the reviewer's typed ask_user {kind, value} from the latest decision, omitted when absent — never answer: null), and — when the item is actionable for this reviewer — openedRefs. answerSchema stays nested on envelope.answerSchema for existing clients.

openedRefs is the gating keys (hitl-spec 3.7) this reviewer has already recorded opens for. It is built from opened audit events written by POST /api/v1/approvals/:id/opens. Reviewer clients hydrate the must-open checklist from it so re-entering an approval does not force opening every item again. The field is omitted when canAct is false. The host still re-validates decide against the recorded events, not against this field.

A project API key on the same route returns the requester view. It keeps the origin-poll fields { id, status, decision?, response?, presentedAt, answerSchema } that Hermes polls while present() waits (answerSchema is the stored ask_user schema, or null when the request has none). When the request has a decided typed ask_user answer, this requester GET also returns top-level answer ({ kind, value } from the stored decision). The key is omitted when there is none — never answer: null. The same response also adds:

  • hitl: the hitl/response/v0 object once the request is closed (null while it is open). status is answered (accept and edit carry value: "approve", reject value: "reject", respond carries the reply text), declined (ignore), cancelled or expired. decidedBy is the reviewer's user id, never their name or email. signature is null for now. HITLy specifics sit in _meta under net.hitly/… keys: net.hitly/decision, net.hitly/editedArgs (edit only), net.hitly/cancelledBy (requester or reviewer).
  • state: the current status, with an overdue pending request reported as expired.
  • argsHash: the JCS hash of the original arguments. The stored request is never changed by an edit.
  • editedArgs: on an edit, the full arguments the reviewer approved (original merged with the edits). Run these, not the original.
  • activity: { presentedAt, items: [{ ref, sha256, openedAt[] }] } for the declared context items.

Any key on the request's project can read it; keys on other projects get 404.

Requester cancel

POST /api/v1/approvals/:id/cancel with the project API key that created the request withdraws an unanswered pending request. Optional body { "reason": "…" }. The request closes as cancelled (net.hitly/cancelledBy: "requester") and the origin is not resumed. Another key, even on the same project, gets 404. An answered, expired or already-closed request returns 409.

Pending requests

GET /api/v1/approvals with a project API key lists the requests that key created which still await a human: pending (not past its deadline), newest first (created_at DESC, id DESC). A human-decided failed_resume row is not listed (its outcome and the failed delivery come from GET /api/v1/approvals/:id).

Query: projectId (optional; must be the key's project), status=open (the default; status=pending is an exact alias of open), limit (1–200, default 50), cursor (opaque; pass the previous page's nextCursor). Invalid cursor is 400. limit is clamped to 200. Unknown status values remain 400.

{
  "projectId": "prj_...",
  "status": "open",
  "items": [
    { "id": "apr_...", "kind": "approval", "status": "pending", "actionName": "send-refund", "idempotencyKey": "run_...:refund", "createdAt": "…", "deadline": "…", "presentedAt": null }
  ],
  "nextCursor": null
}

Requests created before this release have no recorded requester key, so they are not listed and cannot be cancelled with a key; reviewers can still cancel them.

Workspaces and devices

GET /api/v1/workspaces lists memberships. POST /api/v1/workspaces/current with { "workspaceId" } selects one. Mobile also sends x-hitly-workspace-id.

GET /api/v1/workspace returns the current workspace (name, timezone, default SLA, canManage). PATCH /api/v1/workspace with { "name", "timezone", "sla" } updates it (workspace admins).

GET /api/v1/projects lists visible projects. GET /api/v1/projects/:id is the summary. GET/PATCH /api/v1/projects/:id/config is project config for admins (name, SLA, assignee, origin URL; token is write-only). Ingest API keys stay on the web app.

POST /api/v1/devices registers an Expo push token ({ "token", "platform": "ios"|"android" }). DELETE /api/v1/devices unregisters { "token" }. Project API keys are requester credentials (create, read, cancel and list your own requests). Never use them from the reviewer app.

GET /api/v1/health is public: { "ok": true, "product": "hitly", "edition": "oss"|"cloud" }.

POST /api/v1/housekeeping runs due jobs (Authorization: Bearer $HITLY_CRON_SECRET, or unauthenticated in development when the secret is unset). Body is optional: { "job": "expire-overdue-approvals", "force": true }.

See Mobile for the Expo app, deep links, and push payload.

On this page