{
 "openapi": "3.1.0",
 "info": {
  "title": "JaKun API",
  "version": "2026-10-28",
  "description": "The JaKun API is generated from each tenant's metadata: the same endpoints serve every\nobject, built-in or added by a pack. Base URL: `https://jakun.dk/api/v1`.\n\n**Authentication**\n* Integration key — `Authorization: Bearer jk_svc_…` for Records, Metadata and MCP.\n  Issued by the tenant owner in *Indstillinger → API*. Default-deny: a key reaches only\n  the endpoints marked with it here.\n* Signed inbound events — `X-JaKun-Key` + HMAC `X-JaKun-Signature`.\n* Web session — the `jakun_session` cookie of a signed-in owner/admin (management endpoints).\n\n**Test mode.** New keys start in `dry_run`: events are processed and rolled back, and the\nresponse shows what would happen. Switch a key to `live` when the journal looks right.\n\n**Errors** always use one envelope: `{\"error\": {\"code\", \"message\", \"details\"}}` —\nsee [Errors](/docs/errors/). Limits: [Rate limits](/docs/rate-limits/).\nGuides: [docs home](/docs/).\n",
  "contact": {
   "name": "LynBro ApS",
   "url": "https://jakun.dk/en/"
  },
  "termsOfService": "https://jakun.dk/en/legal/terms/"
 },
 "servers": [
  {
   "url": "https://jakun.dk",
   "description": "Production"
  }
 ],
 "tags": [
  {
   "name": "Records",
   "description": "CRUD for any object of the tenant — built-in (`party`, `activity`, …) and objects from installed packs (`lead`, `appointment`, …). One set of endpoints serves every object; fields come from the tenant's metadata (see **Metadata**). Access is limited by the roles of the key or user."
  },
  {
   "name": "Metadata",
   "description": "What objects and fields exist in this tenant. Read this first: field names, types, options and required fields for the Records endpoints."
  },
  {
   "name": "MCP",
   "description": "Model Context Protocol over JSON-RPC for LLM agents. Tools are generated from the metadata (`list_/get_/create_/update_/history_<object>`) plus pack tools. Writes default to `dry_run=true`. See [MCP guide](/docs/mcp/)."
  },
  {
   "name": "Inbound events",
   "description": "Signed events from other systems (cbot, virtual_pbx, sms-geteway, bkg, jatid, …) and the journal of everything received. See [Inbound events guide](/docs/inbound-events/)."
  },
  {
   "name": "API keys",
   "description": "Integration keys of the tenant. **Web session of an owner/admin only** (`can_manage_integrations`); integration keys can't manage keys."
  },
  {
   "name": "Webhooks",
   "description": "Outgoing webhooks: subscriptions, test events, delivery log, retries. Web session of an owner/admin. See [Webhooks guide](/docs/webhooks/)."
  },
  {
   "name": "Connections",
   "description": "Status of LynBro products connected to the tenant: keys, mode, last event, failures in 24 h, health. Web session of an owner/admin."
  },
  {
   "name": "Service",
   "description": "Liveness and readiness for monitoring."
  }
 ],
 "paths": {
  "/api/v1/inbound/{tenant}": {
   "post": {
    "tags": [
     "Inbound events"
    ],
    "summary": "Receive a signed event",
    "parameters": [
     {
      "name": "tenant",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Tenant"
      }
     },
     {
      "name": "x-jakun-key",
      "in": "header",
      "required": false,
      "schema": {
       "type": "string",
       "default": "",
       "title": "X-Jakun-Key"
      }
     },
     {
      "name": "x-jakun-signature",
      "in": "header",
      "required": false,
      "schema": {
       "type": "string",
       "default": "",
       "title": "X-Jakun-Signature"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {},
        "example": {
         "data": {
          "event_id": "call-8812",
          "type": "contact_event",
          "mode": "dry_run",
          "status": "dry_run",
          "result": {
           "outcome": "lead",
           "lead_id": "3f1c…",
           "party_id": "9a0e…"
          }
         }
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "No bearer: authenticate with `X-JaKun-Key` and an HMAC-SHA256 signature of the raw body in `X-JaKun-Signature: t=<unix>,v1=<hex>` (±300 s). Idempotent by `(source, id)`: a repeat returns `duplicate`; a `failed` event may be resent with the same id. Body ≤ 256 KB.",
    "security": [
     {
      "inboundKey": [],
      "inboundSignature": []
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       },
       "example": {
        "id": "call-8812",
        "type": "contact_event",
        "source": "virtual_pbx",
        "occurred_at": "2026-10-28T09:12:44Z",
        "data": {
         "channel": "call",
         "external_id": "call-8812",
         "contact": {
          "phone": "+4500000201"
         },
         "intent": "lead"
        }
       }
      }
     }
    },
    "operationId": "post__inbound_tenant"
   }
  },
  "/api/v1/integrations/keys": {
   "get": {
    "tags": [
     "API keys"
    ],
    "summary": "List integration keys",
    "description": "Keys of this tenant, newest last. Secrets are never returned here.\n\n`meta.roles` — tenant roles a key may get; `meta.sources` — LynBro products\nthat send events.",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Keys List Api V1 Integrations Keys Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__integrations_keys"
   },
   "post": {
    "tags": [
     "API keys"
    ],
    "summary": "Create an integration key",
    "description": "Issue a bearer token and a signing secret. **They are shown only in this response.**\n\nNew keys start in `dry_run`, so you can wire up a sender safely and switch to\n`live` once the journal looks right.",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/KeyCreate"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/KeySecrets"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "Name already used (`key_exists`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__integrations_keys"
   }
  },
  "/api/v1/integrations/keys/{key_id}": {
   "patch": {
    "tags": [
     "API keys"
    ],
    "summary": "Change mode or sources",
    "description": "`mode: live` makes inbound events write to the CRM. Revoked keys can't be changed.",
    "parameters": [
     {
      "name": "key_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Key Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/KeyPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/KeyOut"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "patch__integrations_keys_key_id"
   }
  },
  "/api/v1/integrations/keys/{key_id}/rotate": {
   "post": {
    "tags": [
     "API keys"
    ],
    "summary": "Rotate token and signing secret",
    "description": "New bearer and signing secret; the old ones stop working immediately.",
    "parameters": [
     {
      "name": "key_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Key Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/KeySecrets"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__integrations_keys_key_id_rotate"
   }
  },
  "/api/v1/integrations/keys/{key_id}/revoke": {
   "post": {
    "tags": [
     "API keys"
    ],
    "summary": "Revoke a key",
    "description": "Immediately: REST/MCP answer 401, inbound events answer 401 `bad_key`. Irreversible.",
    "parameters": [
     {
      "name": "key_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Key Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/KeyOut"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__integrations_keys_key_id_revoke"
   }
  },
  "/api/v1/webhooks": {
   "get": {
    "tags": [
     "Webhooks"
    ],
    "summary": "List subscriptions",
    "description": "Subscriptions with delivery counts for the last 24 h (`stats_24h`). No secrets.",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Webhooks List Api V1 Webhooks Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__webhooks"
   },
   "post": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Subscribe",
    "description": "Creates a subscription. **`secret` is returned only here** — verify\n`X-Jakun-Signature` with it. URL must be public `https://`.",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookIn"
       }
      }
     },
     "required": true
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Webhooks Subscribe Api V1 Webhooks Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__webhooks"
   }
  },
  "/api/v1/webhooks/event-types": {
   "get": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Event types you can subscribe to",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Webhooks Event Types Api V1 Webhooks Event Types Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__webhooks_event_types"
   }
  },
  "/api/v1/webhooks/{webhook_id}": {
   "patch": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Update or pause",
    "description": "Change URL, filters, name or `enabled`. Re-enabling resets the failure counter.",
    "parameters": [
     {
      "name": "webhook_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Webhook Id"
      },
      "description": "Only this subscription"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/WebhookPatch"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Update Api V1 Webhooks  Webhook Id  Patch"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "patch__webhooks_webhook_id"
   },
   "delete": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Delete a subscription",
    "description": "Deletes the subscription and its delivery log.",
    "parameters": [
     {
      "name": "webhook_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Webhook Id"
      },
      "description": "Only this subscription"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Delete Api V1 Webhooks  Webhook Id  Delete"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "delete__webhooks_webhook_id"
   }
  },
  "/api/v1/webhooks/{webhook_id}/rotate": {
   "post": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Rotate the secret",
    "description": "New signing secret, shown once. The old one stops working immediately.",
    "parameters": [
     {
      "name": "webhook_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Webhook Id"
      },
      "description": "Only this subscription"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Rotate Api V1 Webhooks  Webhook Id  Rotate Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__webhooks_webhook_id_rotate"
   }
  },
  "/api/v1/webhooks/{webhook_id}/test": {
   "post": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Send a test event",
    "description": "Sends `webhook.test` right now (no queue, no retries) and returns the receiver's\nanswer. Contains no customer data. Logged in the delivery journal.",
    "parameters": [
     {
      "name": "webhook_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Webhook Id"
      },
      "description": "Only this subscription"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Test Api V1 Webhooks  Webhook Id  Test Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__webhooks_webhook_id_test"
   }
  },
  "/api/v1/webhooks/deliveries": {
   "get": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Delivery log",
    "description": "Newest first. Page with `before_id` = last `id` of the previous page.",
    "parameters": [
     {
      "name": "status",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "enum": [
          "pending",
          "retry",
          "delivered",
          "dead"
         ],
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Status"
      },
      "description": "Filter by status"
     },
     {
      "name": "webhook_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Webhook Id"
      },
      "description": "Only this subscription"
     },
     {
      "name": "before_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "integer"
        },
        {
         "type": "null"
        }
       ],
       "title": "Before Id"
      },
      "description": "Next page: the last `id` of the previous page"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size, max 200"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Deliveries Api V1 Webhooks Deliveries Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__webhooks_deliveries"
   }
  },
  "/api/v1/webhooks/deliveries/{delivery_id}": {
   "get": {
    "tags": [
     "Webhooks"
    ],
    "summary": "One delivery: payload and every attempt",
    "parameters": [
     {
      "name": "delivery_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer",
       "title": "Delivery Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Delivery Api V1 Webhooks Deliveries  Delivery Id  Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__webhooks_deliveries_delivery_id"
   }
  },
  "/api/v1/webhooks/dispatch": {
   "post": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Deliver due events now",
    "description": "Does what the background worker does, now, for this tenant.",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size, max 200"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Dispatch Api V1 Webhooks Dispatch Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__webhooks_dispatch"
   }
  },
  "/api/v1/webhooks/deliveries/{delivery_id}/replay": {
   "post": {
    "tags": [
     "Webhooks"
    ],
    "summary": "Retry a delivery (also from the dead-letter queue)",
    "parameters": [
     {
      "name": "delivery_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer",
       "title": "Delivery Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Webhooks Replay Api V1 Webhooks Deliveries  Delivery Id  Replay Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__webhooks_deliveries_delivery_id_replay"
   }
  },
  "/api/v1/inbound/events": {
   "get": {
    "tags": [
     "Inbound events"
    ],
    "summary": "Inbound event journal",
    "description": "Everything senders posted to `/inbound/{tenant}`, newest first, with filters.\n`meta.facets` — values present in the journal with counts (for filter menus).",
    "parameters": [
     {
      "name": "source",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Source"
      },
      "description": "Sender, e.g. `cbot`, `bkg`"
     },
     {
      "name": "type",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Type"
      },
      "description": "Event type, e.g. `contact_event`"
     },
     {
      "name": "status",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "enum": [
          "processed",
          "dry_run",
          "stored",
          "failed"
         ],
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Status"
      },
      "description": "Filter by status"
     },
     {
      "name": "before_id",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "integer"
        },
        {
         "type": "null"
        }
       ],
       "title": "Before Id"
      },
      "description": "Next page: the last `id` of the previous page"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size, max 200"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Inbound List Api V1 Inbound Events Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__inbound_events"
   }
  },
  "/api/v1/inbound/events/{event_row_id}": {
   "get": {
    "tags": [
     "Inbound events"
    ],
    "summary": "One inbound event with payload and result",
    "parameters": [
     {
      "name": "event_row_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer",
       "title": "Event Row Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Inbound Get Api V1 Inbound Events  Event Row Id  Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__inbound_events_event_row_id"
   }
  },
  "/api/v1/inbound/events/{event_row_id}/retry": {
   "post": {
    "tags": [
     "Inbound events"
    ],
    "summary": "Process a failed / stored / dry-run event again",
    "description": "Runs the handler again with the key's **current** mode — retrying a `dry_run`\nevent after switching the key to `live` applies it. Test events stay `dry_run`.",
    "parameters": [
     {
      "name": "event_row_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer",
       "title": "Event Row Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Inbound Retry Api V1 Inbound Events  Event Row Id  Retry Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "`not_retryable`, `no_handler`, `key_revoked`",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__inbound_events_event_row_id_retry"
   }
  },
  "/api/v1/integrations/connections": {
   "get": {
    "tags": [
     "Connections"
    ],
    "summary": "LynBro products: connection and health",
    "description": "One row per LynBro product: keys and mode, last event, failures in 24 h,\nhealthcheck (cached 60 s), cabinet link.",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Connections List Api V1 Integrations Connections Get"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__integrations_connections"
   }
  },
  "/api/v1/integrations/connections/{source}/test": {
   "post": {
    "tags": [
     "Connections"
    ],
    "summary": "Send a dry-run test event from a product",
    "description": "Runs a typical event of that product through the real handler **in dry_run**\n(rolled back — nothing is written, nobody is contacted) and logs it in the journal\nwith id `jakun-test-…`.",
    "parameters": [
     {
      "name": "source",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Source"
      },
      "description": "Sender, e.g. `cbot`, `bkg`"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Connections Test Api V1 Integrations Connections  Source  Test Post"
        }
       }
      }
     },
     "403": {
      "description": "Not allowed: needs `can_manage_integrations` (code `integrations_admin_only`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "404": {
      "description": "Not found",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "409": {
      "description": "`no_key` — no active key for this source",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "post__integrations_connections_source_test"
   }
  },
  "/api/v1/meta/objects": {
   "get": {
    "tags": [
     "Metadata"
    ],
    "summary": "List objects",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Meta Objects Api V1 Meta Objects Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "Objects visible to the caller with labels in da/en/uk.",
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "get__meta_objects"
   }
  },
  "/api/v1/meta/objects/{name}": {
   "get": {
    "tags": [
     "Metadata"
    ],
    "summary": "Describe an object",
    "description": "Fields with type, options, required and validation rules.",
    "parameters": [
     {
      "name": "name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Name"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Meta Object Api V1 Meta Objects  Name  Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "get__meta_objects_name"
   }
  },
  "/api/v1/meta/field-types": {
   "get": {
    "tags": [
     "Metadata"
    ],
    "summary": "Field type catalog",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Meta Field Types Api V1 Meta Field Types Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__meta_field_types"
   }
  },
  "/api/v1/mcp": {
   "post": {
    "tags": [
     "MCP"
    ],
    "summary": "MCP endpoint (JSON-RPC 2.0)",
    "description": "Methods: `initialize`, `tools/list`, `tools/call`, `ping`.",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       },
       "example": {
        "jsonrpc": "2.0",
        "id": 1,
        "method": "tools/call",
        "params": {
         "name": "find_contact",
         "arguments": {
          "phone": "+4500000201"
         }
        }
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {}
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "post__mcp"
   }
  },
  "/api/v1/mcp/tools": {
   "get": {
    "tags": [
     "MCP"
    ],
    "summary": "Tool catalog",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Mcp Tools Api V1 Mcp Tools Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "The same tools as `tools/list`, as plain JSON — for browsing.",
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "get__mcp_tools"
   }
  },
  "/api/v1/search": {
   "get": {
    "tags": [
     "Records"
    ],
    "summary": "Search across objects",
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "required": true,
      "schema": {
       "type": "string",
       "minLength": 2,
       "title": "Q"
      },
      "description": "Search text"
     },
     {
      "name": "objects",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Objects"
      },
      "description": "Comma-separated object names"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 25,
       "default": 5,
       "title": "Limit"
      },
      "description": "Page size, max 200"
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Global Search Api V1 Search Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__search"
   }
  },
  "/api/v1/{object_name}": {
   "get": {
    "tags": [
     "Records"
    ],
    "summary": "List records",
    "description": "Newest first by default. Page with `cursor` = `next_cursor` of the previous page while `has_more` is true.\n\n**Filters** — JSON domain, same syntax everywhere in JaKun:\n`[\"and\", [\"stage\", \"in\", [\"new\", \"contacted\"]], [\"title\", \"ilike\", \"bad\"]]`\n\nOperators: `= != > >= < <= like ilike in`, `not in`, `is null`, `is not null`, `contains`, `between`. Values: `$me` (current user), `$now`, `$now-5d`.",
    "parameters": [
     {
      "name": "object_name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "lead"
      },
      "description": "Object name from `GET /meta/objects`, e.g. `party`, `lead`"
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "minimum": 1,
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size, max 200"
     },
     {
      "name": "cursor",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Cursor"
      },
      "description": "`next_cursor` from the previous page"
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "integer",
         "minimum": 0
        },
        {
         "type": "null"
        }
       ],
       "title": "Offset"
      }
     },
     {
      "name": "page",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "integer",
         "minimum": 1
        },
        {
         "type": "null"
        }
       ],
       "title": "Page"
      }
     },
     {
      "name": "filters",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Filters"
      },
      "description": "JSON domain, e.g. `[\"and\", [\"stage\", \"=\", \"new\"]]`"
     },
     {
      "name": "order",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Order"
      },
      "description": "Sort: `stage:asc,created_at:desc`"
     },
     {
      "name": "q",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Q"
      },
      "description": "Search text"
     },
     {
      "name": "phone",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Phone"
      }
     },
     {
      "name": "email",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Email"
      }
     },
     {
      "name": "tag",
      "in": "query",
      "required": false,
      "schema": {
       "anyOf": [
        {
         "type": "string"
        },
        {
         "type": "null"
        }
       ],
       "title": "Tag"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response List Records Api V1  Object Name  Get"
        },
        "example": {
         "data": [
          {
           "id": "3f1c2a9e-8d3b-4c55-9a51-2e0c0b7f4d11",
           "title": "Nyt badeværelse 8 m²",
           "stage": "new",
           "source": "website",
           "owner_id": null,
           "created_at": "2026-10-28T09:12:44Z",
           "updated_at": "2026-10-28T09:12:44Z"
          }
         ],
         "has_more": false,
         "next_cursor": null
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "get__object_name"
   },
   "post": {
    "tags": [
     "Records"
    ],
    "summary": "Create a record",
    "parameters": [
     {
      "name": "object_name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "lead"
      },
      "description": "Object name from `GET /meta/objects`, e.g. `party`, `lead`"
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       },
       "example": {
        "title": "Nyt badeværelse 8 m²",
        "stage": "new",
        "source": "website"
       }
      }
     }
    },
    "responses": {
     "201": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Create Record Api V1  Object Name  Post"
        },
        "example": {
         "id": "3f1c2a9e-8d3b-4c55-9a51-2e0c0b7f4d11",
         "title": "Nyt badeværelse 8 m²",
         "stage": "new",
         "source": "website",
         "owner_id": null,
         "created_at": "2026-10-28T09:12:44Z",
         "updated_at": "2026-10-28T09:12:44Z"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "Body: field values by name. Unknown fields → 422. Required fields, formats (email, +45 phone), money and limits are validated from the metadata.",
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "post__object_name"
   }
  },
  "/api/v1/{object_name}/{record_id}": {
   "get": {
    "tags": [
     "Records"
    ],
    "summary": "Retrieve a record",
    "description": "A merged duplicate resolves to the surviving record; the response then has `_merged_from`.",
    "parameters": [
     {
      "name": "object_name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "lead"
      },
      "description": "Object name from `GET /meta/objects`, e.g. `party`, `lead`"
     },
     {
      "name": "record_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Record Id"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Get Record Api V1  Object Name   Record Id  Get"
        },
        "example": {
         "id": "3f1c2a9e-8d3b-4c55-9a51-2e0c0b7f4d11",
         "title": "Nyt badeværelse 8 m²",
         "stage": "new",
         "source": "website",
         "owner_id": null,
         "created_at": "2026-10-28T09:12:44Z",
         "updated_at": "2026-10-28T09:12:44Z"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "get__object_name_record_id"
   },
   "patch": {
    "tags": [
     "Records"
    ],
    "summary": "Update a record",
    "parameters": [
     {
      "name": "object_name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "lead"
      },
      "description": "Object name from `GET /meta/objects`, e.g. `party`, `lead`"
     },
     {
      "name": "record_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Record Id"
      }
     }
    ],
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object"
       },
       "example": {
        "stage": "contacted"
       }
      }
     }
    },
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Update Record Api V1  Object Name   Record Id  Patch"
        },
        "example": {
         "id": "3f1c2a9e-8d3b-4c55-9a51-2e0c0b7f4d11",
         "title": "Nyt badeværelse 8 m²",
         "stage": "contacted",
         "source": "website",
         "owner_id": null,
         "created_at": "2026-10-28T09:12:44Z",
         "updated_at": "2026-10-28T09:12:44Z"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "Partial update: only the fields you send change.",
    "security": [
     {
      "serviceKey": []
     },
     {
      "session": []
     }
    ],
    "operationId": "patch__object_name_record_id"
   },
   "delete": {
    "tags": [
     "Records"
    ],
    "summary": "Delete a record",
    "parameters": [
     {
      "name": "object_name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "lead"
      },
      "description": "Object name from `GET /meta/objects`, e.g. `party`, `lead`"
     },
     {
      "name": "record_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Record Id"
      }
     },
     {
      "name": "hard",
      "in": "query",
      "required": false,
      "schema": {
       "type": "boolean",
       "default": false,
       "title": "Hard"
      }
     }
    ],
    "responses": {
     "204": {
      "description": "Successful Response"
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "Soft delete; restorable from the web app. Integration keys can't delete.",
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "delete__object_name_record_id"
   }
  },
  "/api/v1/{object_name}/{record_id}/history": {
   "get": {
    "tags": [
     "Records"
    ],
    "summary": "Record timeline",
    "parameters": [
     {
      "name": "object_name",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "example": "lead"
      },
      "description": "Object name from `GET /meta/objects`, e.g. `party`, `lead`"
     },
     {
      "name": "record_id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "title": "Record Id"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "schema": {
       "type": "integer",
       "maximum": 200,
       "default": 50,
       "title": "Limit"
      },
      "description": "Page size, max 200"
     },
     {
      "name": "audited_only",
      "in": "query",
      "required": false,
      "schema": {
       "type": "boolean",
       "default": false,
       "title": "Audited Only"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "additionalProperties": true,
         "title": "Response Record History Api V1  Object Name   Record Id  History Get"
        }
       }
      }
     },
     "401": {
      "description": "Missing, unknown or revoked credentials (`unauthenticated`, `bad_key`, `bad_signature`, `stale_signature`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "description": "Changes of the record, newest first.",
    "security": [
     {
      "session": []
     }
    ],
    "operationId": "get__object_name_record_id_history"
   }
  },
  "/healthz": {
   "get": {
    "tags": [
     "Service"
    ],
    "summary": "Liveness",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {
         "additionalProperties": true,
         "type": "object",
         "title": "Response Healthz Healthz Get"
        },
        "example": {
         "status": "ok"
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [],
    "operationId": "get__healthz"
   }
  },
  "/readyz": {
   "get": {
    "tags": [
     "Service"
    ],
    "summary": "Readiness (database)",
    "responses": {
     "200": {
      "description": "Successful Response",
      "content": {
       "application/json": {
        "schema": {},
        "example": {
         "status": "ok",
         "db": true
        }
       }
      }
     },
     "403": {
      "description": "Authenticated but not allowed (`service_scope`, `integrations_admin_only`, `source_not_allowed`, …)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "422": {
      "description": "Body or parameters don't match the schema (`validation_failed`)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limit of the key (`rate_limited`) — wait `Retry-After` seconds",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     }
    },
    "security": [],
    "operationId": "get__readyz"
   }
  }
 },
 "components": {
  "schemas": {
   "KeyCreate": {
    "properties": {
     "name": {
      "type": "string",
      "title": "Name",
      "description": "Unique per tenant, `a-z0-9_.-`",
      "examples": [
       "cbot"
      ]
     },
     "sources": {
      "items": {
       "type": "string"
      },
      "type": "array",
      "title": "Sources",
      "description": "Allowed `source` values in inbound events. Default: `[name]`",
      "examples": [
       [
        "cbot"
       ]
      ]
     },
     "roles": {
      "items": {
       "type": "string"
      },
      "type": "array",
      "title": "Roles",
      "description": "Tenant roles of the key. Default: `byg_agent`"
     },
     "mode": {
      "type": "string",
      "enum": [
       "dry_run",
       "live"
      ],
      "title": "Mode",
      "default": "dry_run"
     }
    },
    "type": "object",
    "required": [
     "name"
    ],
    "title": "KeyCreate"
   },
   "KeyOut": {
    "properties": {
     "key_id": {
      "type": "string",
      "title": "Key Id",
      "examples": [
       "key_3fa9c1d2e4b5"
      ]
     },
     "name": {
      "type": "string",
      "title": "Name",
      "examples": [
       "cbot"
      ]
     },
     "roles": {
      "items": {
       "type": "string"
      },
      "type": "array",
      "title": "Roles",
      "examples": [
       [
        "byg_agent"
       ]
      ]
     },
     "sources": {
      "items": {
       "type": "string"
      },
      "type": "array",
      "title": "Sources",
      "examples": [
       [
        "cbot"
       ]
      ]
     },
     "mode": {
      "type": "string",
      "enum": [
       "dry_run",
       "live"
      ],
      "title": "Mode",
      "description": "`dry_run` — events are processed and rolled back; `live` — written"
     },
     "created_at": {
      "anyOf": [
       {
        "type": "string",
        "format": "date-time"
       },
       {
        "type": "null"
       }
      ],
      "title": "Created At"
     },
     "last_used_at": {
      "anyOf": [
       {
        "type": "string",
        "format": "date-time"
       },
       {
        "type": "null"
       }
      ],
      "title": "Last Used At",
      "description": "Last REST/MCP call with the bearer"
     },
     "last_event_at": {
      "anyOf": [
       {
        "type": "string",
        "format": "date-time"
       },
       {
        "type": "null"
       }
      ],
      "title": "Last Event At",
      "description": "Last signed inbound event"
     },
     "revoked_at": {
      "anyOf": [
       {
        "type": "string",
        "format": "date-time"
       },
       {
        "type": "null"
       }
      ],
      "title": "Revoked At"
     }
    },
    "type": "object",
    "required": [
     "key_id",
     "name",
     "roles",
     "sources",
     "mode"
    ],
    "title": "KeyOut"
   },
   "KeyPatch": {
    "properties": {
     "mode": {
      "anyOf": [
       {
        "type": "string",
        "enum": [
         "dry_run",
         "live"
        ]
       },
       {
        "type": "null"
       }
      ],
      "title": "Mode"
     },
     "sources": {
      "anyOf": [
       {
        "items": {
         "type": "string"
        },
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Sources"
     }
    },
    "type": "object",
    "title": "KeyPatch"
   },
   "KeySecrets": {
    "properties": {
     "key": {
      "$ref": "#/components/schemas/KeyOut"
     },
     "token": {
      "type": "string",
      "title": "Token",
      "description": "`Authorization: Bearer …` for REST and MCP",
      "examples": [
       "jk_svc_…"
      ]
     },
     "signing_secret": {
      "type": "string",
      "title": "Signing Secret",
      "description": "HMAC secret for `X-JaKun-Signature`",
      "examples": [
       "jk_whsec_…"
      ]
     },
     "env": {
      "type": "string",
      "title": "Env",
      "description": "Ready-to-paste `.env` block"
     }
    },
    "type": "object",
    "required": [
     "key",
     "token",
     "signing_secret",
     "env"
    ],
    "title": "KeySecrets",
    "description": "Shown ONCE. Store in the sender's `.env`; JaKun keeps only a hash and a cipher."
   },
   "WebhookIn": {
    "properties": {
     "name": {
      "type": "string",
      "title": "Name",
      "default": "webhook",
      "examples": [
       "Zapier"
      ]
     },
     "url": {
      "type": "string",
      "title": "Url",
      "examples": [
       "https://hooks.example.com/jakun"
      ]
     },
     "events": {
      "anyOf": [
       {
        "items": {
         "type": "string"
        },
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Events",
      "description": "Event types; empty or null = all",
      "examples": [
       [
        "record.created"
       ]
      ]
     },
     "objects": {
      "anyOf": [
       {
        "items": {
         "type": "string"
        },
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Objects",
      "description": "Object names; empty or null = all",
      "examples": [
       [
        "lead"
       ]
      ]
     }
    },
    "type": "object",
    "required": [
     "url"
    ],
    "title": "WebhookIn"
   },
   "WebhookPatch": {
    "properties": {
     "name": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Name"
     },
     "url": {
      "anyOf": [
       {
        "type": "string"
       },
       {
        "type": "null"
       }
      ],
      "title": "Url"
     },
     "events": {
      "anyOf": [
       {
        "items": {
         "type": "string"
        },
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Events"
     },
     "objects": {
      "anyOf": [
       {
        "items": {
         "type": "string"
        },
        "type": "array"
       },
       {
        "type": "null"
       }
      ],
      "title": "Objects"
     },
     "enabled": {
      "anyOf": [
       {
        "type": "boolean"
       },
       {
        "type": "null"
       }
      ],
      "title": "Enabled"
     }
    },
    "type": "object",
    "title": "WebhookPatch"
   },
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "object",
      "required": [
       "code",
       "message"
      ],
      "properties": {
       "code": {
        "type": "string",
        "description": "Stable machine code — switch on this",
        "example": "integrations_admin_only"
       },
       "message": {
        "type": "string",
        "description": "Human text; may change"
       },
       "details": {
        "description": "Code-specific extra data",
        "nullable": true
       }
      }
     }
    }
   }
  },
  "securitySchemes": {
   "serviceKey": {
    "type": "http",
    "scheme": "bearer",
    "bearerFormat": "jk_svc_…",
    "description": "Integration key from Indstillinger → API"
   },
   "session": {
    "type": "apiKey",
    "in": "cookie",
    "name": "jakun_session",
    "description": "Web session of a signed-in user"
   },
   "inboundKey": {
    "type": "apiKey",
    "in": "header",
    "name": "X-JaKun-Key",
    "description": "`key_…` of the integration key"
   },
   "inboundSignature": {
    "type": "apiKey",
    "in": "header",
    "name": "X-JaKun-Signature",
    "description": "`t=<unix>,v1=<hex HMAC-SHA256(secret, \"<unix>.\" + raw body)>`"
   }
  }
 }
}