Error codes
Every surface returns the exact same machine-readable error envelope. Branch control flow on code and details, never on human prose in message.
KernelErrorShape contract#
REST v2 error bodies, MCP isError: true tool results, @honeloop/sdkexceptions and hl CLI JSON error envelopes all carry the exact same five-field object: code, message, optional remediation, optionaldetails and optional retry_after (integer seconds).
- No
correlation_idin the body: the correlation ID travels in theX-Correlation-IdHTTP response header (and in MCP result_meta) on every response, success or failure. - Append-only codes: shipped codes are never renamed, removed or reassigned to a different HTTP status. Clients must handle unknown future codes gracefully by HTTP status class.
approval_requiredis not an error: policy diversion is a success-shaped HTTP 202 response documented inApprovals and autonomy.
Example error response (HTTP 403)
{
"code": "scope_missing",
"message": "Principal lacks required scope approvals:decide.",
"remediation": {
"hint": "Authenticate with a reviewer principal holding approvals:decide."
},
"details": {
"required_scope": "approvals:decide",
"held_scopes": ["posts:read", "posts:write", "posts:publish", "channels:read"]
}
}Live preflight validator#
Honeloop validates every post against the destination channel's manifest before scheduling or calling an upstream platform. Pick a platform and edit the draft below to watch the response switch between 400 validation_failed (with rule_id and remediation) and 200 ok using the real manifest counting rules — grapheme counting for Bluesky, weighted URL=23 and CJK=2 counting for X, and exact UTF-16 or grapheme limits across LinkedIn, Threads, Instagram, TikTok and YouTube.
Unicode grapheme counting (Intl.Segmenter). up to 4 images, up to 1 video (one kind per part).
{
"code": "validation_failed",
"message": "Post failed 1 manifest check for Bluesky.",
"remediation": {
"hint": "Shorten part 1 by 67 characters.",
"docs_url": "/docs/errors/#err-validation_failed"
},
"details": {
"provider_id": "bluesky",
"manifest_revision": 10,
"counting": "grapheme",
"measured": 367,
"limit": 300,
"errors": [
{
"rule_id": "text.max_length",
"part_index": 0,
"field": "text",
"message": "Part 1 is 367 characters long; the limit is 300.",
"remediation": "Shorten part 1 by 67 characters."
}
]
}
}Bluesky: 400 validation_failed (367 of 300 characters). Shorten part 1 by 67 characters.
Complete error catalog#
Generated directly from packages/schemas/src/common/errors.ts and verified against drift in CI. Every code links from theREST v2 reference.
| Code | HTTP | Stage | Retryable | When and remediation |
|---|---|---|---|---|
capability_unknown | 404 | Stage 0 | no | The requested capability name or version is not in the frozen registry. Details: None (no capability enumeration for unauthenticated callers). Remediation: Check the capability path against the REST v2 reference. |
capability_retired | 410 | Stage 0 | no | The capability version passed its sunset date. Details: { retired_at, replacement? } Remediation: Migrate to the replacement capability named in remediation.capability. |
unauthenticated | 401 | Stage 1 | no | The Authorization Bearer token is missing, malformed, unknown or revoked. Details: None. Remediation: Supply a valid hlk_ API key, hlt_ OAuth token or session JWT in Authorization: Bearer. |
principal_disabled | 403 | Stage 1 | no | The authenticated principal is suspended or revoked, or the membership was removed. Details: { principal_id, status } Remediation: Ask a workspace admin or operator to issue a new key or restore membership. |
grant_expired | 403 | Stage 2 | no | The delegated Grant behind an agent token expired or was revoked. Details: { grant_id, on_behalf_of, expired_at } Remediation: Request a fresh delegation grant from the user. |
scope_missing | 403 | Stage 3 | no | The principal's effective scopes do not include the capability's required scope. Details: { required_scope, held_scopes } Remediation: Use a principal that holds required_scope. Never expect approvals:decide on an agent key. |
validation_failed | 400 | Stage 4 | no | Input JSON failed TypeBox schema validation or provider manifest content constraints. Details: { errors: [{ path?, keyword?, rule_id?, channel_id?, part_index?, field?, message, remediation? }] } Remediation: Fix every reported field or content constraint before retrying; never retry unchanged. |
idempotency_key_required | 400 | Stage 4 | no | An Idempotency-Key header was omitted on a capability whose policy is required. Details: { capability } Remediation: Generate a unique Idempotency-Key (UUIDv7 recommended; 8 to 128 ASCII chars on posts.schedule) and retry. |
payload_too_large | 413 | Stage 4 | no | The request body exceeded the transport limit (1 MiB for JSON capability calls). Details: { limit_bytes, received_bytes } Remediation: Reduce request size or upload large media through media.upload first. |
idempotency_mismatch | 409 | Stage 5 | no | An Idempotency-Key was reused within 24 hours with a different canonical request payload. Details: { key, original_request_hash, original_created_at } Remediation: Mint a new Idempotency-Key for distinct payloads; reuse a key only when retrying the exact same intent. |
idempotency_in_flight | 409 | Stage 5 | yes | Another request with the same Idempotency-Key is still executing. Details: { key } plus retry_after (typically 5 seconds). Remediation: Wait retry_after seconds and retry with the same Idempotency-Key to receive the canonical response. |
entitlement_exceeded | 402 | Stage 6 | no | The workspace reached a plan limit (channels, seats, keys or monthly posts). Details: { limit_type, limit, used, tier } Remediation: Free unused resources or upgrade the workspace plan. |
policy_forbidden | 403 | Stage 7 | no | An organisation-authored policy rule (such as quiet hours with effect deny) forbade the call. Details: { rule_id, policy_scope, reason? } Remediation: Adjust the target slot or ask an admin to review the workspace policy. |
guardrail_forbidden | 403 | Stage 7 | no | A shipped platform guardrail or separation-of-duties rule forbade the action outright. Details: { guardrail, platform, guardrail_version } or offending_renditions[]. Remediation: Cannot be bypassed by approval or policy; remove the offending channel or use an independent reviewer. |
rate_limited | 429 | Stage 8 | yes | Per-principal or per-org request bucket is empty, or a channel daily cap filled in flight. Details: { scope, class } plus retry_after (daily cap adds cap_type, limit, used, channel_id, day). Remediation: Wait retry_after seconds before retrying. Respect the Retry-After response header. |
not_found | 404 | Stage 9 | no | The referenced post, channel, approval request, media item or resource does not exist in this organisation. Details: { resource_type, id } Remediation: Verify the UUIDv7 id and organisation binding; cross-organisation ids also return not_found. |
conflict_stale_version | 409 | Stage 9 | no | Optimistic-lock version did not match the current row version. Details: { your_version, current_version, current }. Remediation: Inspect details.current, merge your change onto current_version and retry (or use withRebase in the SDK). |
channel_needs_reauth | 422 | Stage 9 | no | A target channel's stored platform credential expired or was revoked. Details: { channel_id, provider_id } with remediation.capability. Remediation: Reconnect the channel in the web app or via channels.connect_credentials / channels.connect_url. |
platform_rejected | 422 | Stage 9 | no | The upstream social platform synchronously rejected the content or credentials. Details: { channel_id?, provider_id, platform_code?, platform_message?, violated_constraint? } Remediation: Fix the rejected content or credentials; inspect providers.capabilities for updated rules. |
timeout | 504 | Stage 9 | yes | The capability exceeded its synchronous handler time budget. Details: { timeout_ms } Remediation: Retry with the same Idempotency-Key for act/irreversible calls after checking status. |
token_expired | 401 | Stage 1 | no | The short-lived session JWT or hlt_ OAuth access token expired. Details: { expired_at } Remediation: Refresh the access token through /v2/auth/refresh or the OAuth token endpoint. |
login_link_invalid | 401 | identity plane | no | The emailed sign-in link token is unknown, expired or was already consumed. Details: None. Remediation: Request a fresh sign-in link; each link is single use and valid for 15 minutes. |
csrf_failed | 403 | identity plane | no | A cookie-authenticated identity route lacked a matching Origin or X-Honeloop-Csrf: 1 header. Details: None. Remediation: Send requests from the application's own origin with X-Honeloop-Csrf: 1. |
role_forbidden | 403 | identity plane | no | The user's workspace role cannot perform this member, invitation or key action. Details: { required_role, role } Remediation: Ask a workspace owner or admin with sufficient role permissions to perform the action. |
token_reused | 401 | Stage 1 | no | A rotated refresh token was presented again, revoking the session family. Details: None. Remediation: Sign in again; coordinate browser refreshes across tabs. |
org_mismatch | 403 | Stage 1 | no | X-Honeloop-Org was empty or did not match the authenticated credential's organisation UUID. Details: None. Remediation: Omit X-Honeloop-Org or send the exact lowercase UUIDv7 of the credential's organisation. |
credential_in_url | 400 | transport | no | A credential-shaped token (hlk_, hlt_, hlr_, hlm_, hli_ or bare secret) appeared in the URL path or query. Details: None. Remediation: Send credentials only in the Authorization: Bearer header and rotate any leaked token immediately. |
method_not_allowed | 405 | transport | no | A non-POST HTTP method was sent to a capability route. Details: None (Allow: POST header included). Remediation: Send POST /v2/<domain>/<verb> with a JSON object body. |
unsupported_media_type | 415 | transport | no | Content-Type was missing or not application/json (or multipart/form-data on media.upload). Details: None. Remediation: Set Content-Type: application/json on capability calls. |
credits_exhausted | 402 | Stage 6 | no | Metered credits or the workspace monthly X pay-per-use cap was reached. Details: { credit_type, required, balance } (X cap adds cap_type, limit, used, period, unit). Remediation: Raise max_x_spend_usd_per_month via policies.set or top up credits. |
budget_exceeded | 402 | Stage 7 | no | A configured spend cap (such as the content agent monthly budget) was reached. Details: { cap_type, limit, used } Remediation: Wait for the next billing period or raise the cap via agent.update_settings / policies.set. |
invalid_state | 409 | Stage 9 | no | The requested transition is not allowed from the entity's current lifecycle state. Details: { state, allowed_transitions } Remediation: Read current status; failed posts cannot return to scheduled or publishing. |
cursor_invalid | 400 | Stage 9 | no | A pagination cursor was malformed, expired or paired with changed filter parameters. Details: None. Remediation: Restart pagination from the first page without a cursor parameter. |
publish_in_progress | 409 | Stage 9 | no | A cancel or reschedule arrived after the publish workflow had already claimed the post. Details: { post_id } Remediation: Poll posts.status for the final publication outcome; it can no longer be cancelled. |
publish_state_unknown | 409 | Stage 9 | no | A mutating publish call timed out, threw an untyped error or exhausted its pending wait. Details: { post_id, rendition_id?, part_index? } with recreate: false. Remediation: NEVER publish again automatically. Inspect the destination channel directly before taking any action. |
published_with_error | 409 | Stage 9 | no | The post is live on the platform, but a follow-up step failed. Details: { post_id, rendition_id, platform_post_id, url } with recreate: false. Remediation: The post is already live. Do not publish again; complete any follow-up step manually. |
channel_disabled | 422 | Stage 9 | no | The target channel was disconnected and its credentials were scrubbed. Details: { channel_id } Remediation: Reconnect the channel before targeting it in a new post. |
platform_unavailable | 502 | Stage 9 | yes | The upstream platform was unavailable after typed Retryable attempts were exhausted. Details: { provider_id } plus optional retry_after. Remediation: Wait and retry; for a failed rendition with recreate: true, create a new post for that channel. |
orchestrator_unavailable | 503 | Stage 9 | yes | Temporal could not start or signal the workflow; the claim was released. Details: None plus retry_after. Remediation: Wait retry_after seconds and retry with the same Idempotency-Key. |
dependency_unavailable | 503 | any | yes | A backing dependency (Postgres, key management or storage) was temporarily unreachable. Details: None plus retry_after. Remediation: Wait retry_after seconds and retry with backoff. |
internal_error | 500 | any | yes | An unexpected internal fault occurred; no internal details are leaked. Details: { correlation_id } (also present in X-Correlation-Id header). Remediation: Retry idempotently with backoff and quote X-Correlation-Id if contacting support. |
CLI exit code map (hl)#
When stdout is not a terminal, hl emits one JSON document on stdout and maps machine error codes to stable exit statuses for scripts and coding agents.
| Exit code | Meaning |
|---|---|
0 | Success, including HTTP 202 approval_required diversions (use --fail-on-diversion to map diversions to exit 10). |
1 | Unexpected or network failure after retries. |
2 | CLI usage error (missing flag, invalid JSON input or client-side schema mismatch). |
3 | validation_failed |
4 | scope_missing |
5 | rate_limited (after SDK retries were exhausted) |
6 | conflict_stale_version (details.current carries the live resource) |
7 | idempotency_mismatch |
8 | channel_needs_reauth |
9 | platform_rejected |
10 | approval_required when --fail-on-diversion is set |
11 | not_found |
12 | credits_exhausted |
13 | Authentication failure (401/403 such as unauthenticated or token_expired) |
14 | publish_state_unknown (recreate: false — never publish again) |
15 | published_with_error (recreate: false — post is already live) |
16 | orchestrator_unavailable, dependency_unavailable or platform_unavailable |
17 | invalid_state |
18 | policy_forbidden or guardrail_forbidden |
19 | idempotency_key_required or idempotency_in_flight |