{"openapi":"3.1.0","info":{"title":"Servunio Developer API","version":"1.0","description":"The Servunio Developer API supports three integration directions:\n\n1. **Calling Servunio** — Execute approved capability contracts (booking, ticketing, lead capture, quoting, catalog lookup) from your own software using tenant-scoped API keys.\n2. **Calling external systems** — Servunio can invoke your registered webhook endpoints when capabilities complete or when workflow steps require external data.\n3. **Receiving webhook events** — Subscribe to real-time event streams (execution lifecycle, booking confirmations, ticket updates) delivered as signed HTTP POST payloads to your endpoint.\n\nAll API keys carry a `sv_live_<prefix>.<secret>` or `sv_test_<prefix>.<secret>` format and are scoped to a single organisation. LIVE keys execute real side-effects; TEST keys are read-only and cannot execute actions.\n\nRate limit: **120 requests/minute** per credential by default (configurable via the `DEVELOPER_API_RATE_LIMIT` environment variable), enforced with atomic Redis counters.","contact":{"email":"support@servunio.com"}},"servers":[{"url":"https://servunio.com/v1/developer","description":"Production"}],"security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"paths":{"/capabilities":{"get":{"operationId":"listCapabilities","summary":"List configured capability contracts","description":"Returns all capability contracts that have been activated for the authenticated organisation. Requires `capabilities:read` or `actions:execute` scope.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"responses":{"200":{"description":"Capability list","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/CapabilityContract"}}}}}}},"400":{"description":"Validation error or missing idempotency key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"examples":{"validationError":{"summary":"Validation error","value":{"code":"VALIDATION_ERROR","message":"Invalid input."}},"idempotencyKeyRequired":{"summary":"Missing idempotency key","value":{"code":"IDEMPOTENCY_KEY_REQUIRED","message":"Write requests require an Idempotency-Key header of at least 8 characters."}}}}}},"401":{"description":"Missing, invalid, or expired API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"statusCode":{"type":"integer","example":401}},"required":["message","statusCode"]}}}},"403":{"description":"Insufficient scope, TEST key restriction, or customer-scoped action","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}]},"examples":{"insufficientScope":{"summary":"Scope denied","value":{"code":"INSUFFICIENT_SCOPE","message":"This API credential requires the 'actions:execute' scope.","requiredScope":"actions:execute"}},"testKeyRestriction":{"summary":"LIVE key required","value":{"message":"Test credentials cannot perform live actions; a sandbox is not configured."}}}}}},"409":{"description":"Idempotency key conflict or execution already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"429":{"description":"API rate limit exceeded (default 120 req/min per credential, configurable via DEVELOPER_API_RATE_LIMIT)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"API rate limit exceeded."}},"required":["message"]}}}},"503":{"description":"Downstream integration temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"example":{"code":"INTEGRATION_UNAVAILABLE","message":"The integration is currently unavailable. Please retry later."}}}}}}},"/actions/{capabilityCode}":{"post":{"operationId":"executeAction","summary":"Execute an approved capability","description":"Triggers execution of a capability contract. Requires `actions:execute` scope (or the capability-specific scope, e.g. `appointments:write` for `booking.create`).\n\n> **LIVE key required.** TEST keys (`sv_test_…`) cannot execute actions and will receive a 403.\n\nEvery mutating request **must** include an `Idempotency-Key` header (8–200 chars). Replaying the same key within the deduplication window returns the original response without re-executing the action.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"name":"capabilityCode","in":"path","required":true,"description":"Dot-namespaced capability identifier, e.g. `booking.create`, `lead.capture`, `catalog.search`.","schema":{"type":"string","pattern":"^[a-z][a-z0-9_.\\-]{1,119}$","example":"booking.create"}},{"name":"Idempotency-Key","in":"header","required":true,"description":"Caller-generated unique key for this request (8–200 chars). Use a UUID or a stable hash of your request payload.","schema":{"type":"string","minLength":8,"maxLength":200,"example":"01J2K3M4-N5P6-Q7R8-S9T0-U1V2W3X4Y5Z6"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["input"],"properties":{"input":{"type":"object","additionalProperties":true,"description":"Capability-specific input payload. Must conform to the `inputSchema` declared in the capability contract."},"customerEmail":{"type":"string","format":"email","description":"Optional email address used to associate this execution with a known customer record."},"conversationId":{"type":"string","format":"uuid","description":"Optional UUID of an existing Servunio conversation to link this execution to. Must belong to the authenticated organisation."},"correlationId":{"type":"string","description":"Optional opaque correlation identifier propagated through logs and webhook payloads for end-to-end tracing."}}},"example":{"input":{"date":"2026-12-15","serviceId":"svc_01J2K3","staffId":"staff_01A2B3"},"customerEmail":"alice@example.com","correlationId":"my-crm-job-9981"}}}},"responses":{"200":{"description":"Execution accepted (or retrieved from idempotency cache)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkflowExecution"}}}},"400":{"description":"Validation error or missing idempotency key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"examples":{"validationError":{"summary":"Validation error","value":{"code":"VALIDATION_ERROR","message":"Invalid input."}},"idempotencyKeyRequired":{"summary":"Missing idempotency key","value":{"code":"IDEMPOTENCY_KEY_REQUIRED","message":"Write requests require an Idempotency-Key header of at least 8 characters."}}}}}},"401":{"description":"Missing, invalid, or expired API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"statusCode":{"type":"integer","example":401}},"required":["message","statusCode"]}}}},"403":{"description":"Insufficient scope, TEST key restriction, or customer-scoped action","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}]},"examples":{"insufficientScope":{"summary":"Scope denied","value":{"code":"INSUFFICIENT_SCOPE","message":"This API credential requires the 'actions:execute' scope.","requiredScope":"actions:execute"}},"testKeyRestriction":{"summary":"LIVE key required","value":{"message":"Test credentials cannot perform live actions; a sandbox is not configured."}}}}}},"409":{"description":"Idempotency key conflict or execution already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"429":{"description":"API rate limit exceeded (default 120 req/min per credential, configurable via DEVELOPER_API_RATE_LIMIT)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"API rate limit exceeded."}},"required":["message"]}}}},"503":{"description":"Downstream integration temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"example":{"code":"INTEGRATION_UNAVAILABLE","message":"The integration is currently unavailable. Please retry later."}}}}}}},"/executions/{executionId}":{"get":{"operationId":"getExecution","summary":"Get workflow execution status","description":"Retrieves the current state of a workflow execution. Requires `actions:read` or `actions:execute` scope.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"name":"executionId","in":"path","required":true,"description":"UUID of the workflow execution.","schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"Execution record","content":{"application/json":{"schema":{"type":"object","required":["id","status","capabilityCode","input","createdAt","updatedAt"],"properties":{"id":{"type":"string","format":"uuid"},"status":{"$ref":"#/components/schemas/ExecutionStatus"},"capabilityCode":{"type":"string","example":"booking.create"},"input":{"type":"object","additionalProperties":true},"output":{"type":"object","additionalProperties":true,"nullable":true},"error":{"type":"string","nullable":true,"description":"Human-readable error message when status is `failed`."},"requiresConfirmation":{"type":"boolean"},"confirmedAt":{"type":"string","format":"date-time","nullable":true},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}}}}},"400":{"description":"Validation error or missing idempotency key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"examples":{"validationError":{"summary":"Validation error","value":{"code":"VALIDATION_ERROR","message":"Invalid input."}},"idempotencyKeyRequired":{"summary":"Missing idempotency key","value":{"code":"IDEMPOTENCY_KEY_REQUIRED","message":"Write requests require an Idempotency-Key header of at least 8 characters."}}}}}},"401":{"description":"Missing, invalid, or expired API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"statusCode":{"type":"integer","example":401}},"required":["message","statusCode"]}}}},"403":{"description":"Insufficient scope, TEST key restriction, or customer-scoped action","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}]},"examples":{"insufficientScope":{"summary":"Scope denied","value":{"code":"INSUFFICIENT_SCOPE","message":"This API credential requires the 'actions:execute' scope.","requiredScope":"actions:execute"}},"testKeyRestriction":{"summary":"LIVE key required","value":{"message":"Test credentials cannot perform live actions; a sandbox is not configured."}}}}}},"404":{"description":"Execution not found or does not belong to this organisation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"example":{"code":"NOT_FOUND","message":"Execution not found."}}}},"409":{"description":"Idempotency key conflict or execution already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"429":{"description":"API rate limit exceeded (default 120 req/min per credential, configurable via DEVELOPER_API_RATE_LIMIT)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"API rate limit exceeded."}},"required":["message"]}}}},"503":{"description":"Downstream integration temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"example":{"code":"INTEGRATION_UNAVAILABLE","message":"The integration is currently unavailable. Please retry later."}}}}}}},"/executions/{executionId}/confirm":{"post":{"operationId":"confirmExecution","summary":"Confirm or reject an execution awaiting approval","description":"Approves or rejects a workflow execution that has status `awaiting_confirmation`. Requires `actions:confirm` or `actions:execute` scope.\n\n> **LIVE key required.** TEST keys cannot perform confirmations.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"name":"executionId","in":"path","required":true,"description":"UUID of the execution to confirm.","schema":{"type":"string","format":"uuid"}},{"name":"Idempotency-Key","in":"header","required":true,"description":"Caller-generated unique key for this confirmation (8–200 chars).","schema":{"type":"string","minLength":8,"maxLength":200}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["approved"],"properties":{"approved":{"type":"boolean","description":"`true` to approve execution, `false` to reject."},"reason":{"type":"string","description":"Optional human-readable reason, logged for audit purposes."}}},"example":{"approved":true,"reason":"Verified with customer over phone."}}}},"responses":{"200":{"description":"Confirmation recorded","content":{"application/json":{"schema":{"type":"object","required":["executionId","status","confirmedAt"],"properties":{"executionId":{"type":"string","format":"uuid"},"status":{"$ref":"#/components/schemas/ExecutionStatus"},"confirmedAt":{"type":"string","format":"date-time"}}}}}},"400":{"description":"Validation error or missing idempotency key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"examples":{"validationError":{"summary":"Validation error","value":{"code":"VALIDATION_ERROR","message":"Invalid input."}},"idempotencyKeyRequired":{"summary":"Missing idempotency key","value":{"code":"IDEMPOTENCY_KEY_REQUIRED","message":"Write requests require an Idempotency-Key header of at least 8 characters."}}}}}},"401":{"description":"Missing, invalid, or expired API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"statusCode":{"type":"integer","example":401}},"required":["message","statusCode"]}}}},"403":{"description":"Insufficient scope, TEST key restriction, or customer-scoped action","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}]},"examples":{"insufficientScope":{"summary":"Scope denied","value":{"code":"INSUFFICIENT_SCOPE","message":"This API credential requires the 'actions:execute' scope.","requiredScope":"actions:execute"}},"testKeyRestriction":{"summary":"LIVE key required","value":{"message":"Test credentials cannot perform live actions; a sandbox is not configured."}}}}}},"409":{"description":"Idempotency key conflict or execution already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"429":{"description":"API rate limit exceeded (default 120 req/min per credential, configurable via DEVELOPER_API_RATE_LIMIT)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"API rate limit exceeded."}},"required":["message"]}}}},"503":{"description":"Downstream integration temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"example":{"code":"INTEGRATION_UNAVAILABLE","message":"The integration is currently unavailable. Please retry later."}}}}}}},"/resources/{resource}":{"get":{"operationId":"listResources","summary":"List tenant resources with cursor pagination","description":"Returns a paginated list of records for the requested resource type. The required scope varies by resource:\n\n| Resource | Required scope |\n|---|---|\n| `appointments` | `appointments:read` |\n| `tickets` | `tickets:read` |\n| `leads` | `leads:read` |\n| `quotes` | `quotes:read` |\n| `catalog` | `catalog:read` |\n| `conversations` | `conversations:read` |\n\nSensitive fields (`internalNotes`, `metadata`, `customerVerified`, `verifiedAt`, `verifiedUntil`) are stripped from all responses.","security":[{"bearerAuth":[]},{"apiKeyHeader":[]}],"parameters":[{"name":"resource","in":"path","required":true,"description":"The resource collection to query.","schema":{"type":"string","enum":["appointments","tickets","leads","quotes","catalog","conversations"]}},{"name":"after","in":"query","required":false,"description":"Cursor for forward pagination. Pass the `nextCursor` value from the previous response.","schema":{"type":"string","format":"uuid"}},{"name":"limit","in":"query","required":false,"description":"Number of records to return. Defaults to 25; maximum 100.","schema":{"type":"integer","minimum":1,"maximum":100,"default":25}}],"responses":{"200":{"description":"Paginated resource list","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaginatedResponse"}}}},"400":{"description":"Validation error or missing idempotency key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"examples":{"validationError":{"summary":"Validation error","value":{"code":"VALIDATION_ERROR","message":"Invalid input."}},"idempotencyKeyRequired":{"summary":"Missing idempotency key","value":{"code":"IDEMPOTENCY_KEY_REQUIRED","message":"Write requests require an Idempotency-Key header of at least 8 characters."}}}}}},"401":{"description":"Missing, invalid, or expired API key","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"},"statusCode":{"type":"integer","example":401}},"required":["message","statusCode"]}}}},"403":{"description":"Insufficient scope, TEST key restriction, or customer-scoped action","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ApiError"},{"type":"object","properties":{"message":{"type":"string"}},"required":["message"]}]},"examples":{"insufficientScope":{"summary":"Scope denied","value":{"code":"INSUFFICIENT_SCOPE","message":"This API credential requires the 'actions:execute' scope.","requiredScope":"actions:execute"}},"testKeyRestriction":{"summary":"LIVE key required","value":{"message":"Test credentials cannot perform live actions; a sandbox is not configured."}}}}}},"409":{"description":"Idempotency key conflict or execution already in progress","content":{"application/json":{"schema":{"$ref":"#/components/schemas/IdempotencyConflict"}}}},"429":{"description":"API rate limit exceeded (default 120 req/min per credential, configurable via DEVELOPER_API_RATE_LIMIT)","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","example":"API rate limit exceeded."}},"required":["message"]}}}},"503":{"description":"Downstream integration temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"},"example":{"code":"INTEGRATION_UNAVAILABLE","message":"The integration is currently unavailable. Please retry later."}}}}}}},"/openapi.json":{"get":{"operationId":"getOpenApiDocument","summary":"Download this OpenAPI specification","description":"Returns the full OpenAPI 3.1.0 document describing the Servunio Developer API. No authentication required.","security":[],"responses":{"200":{"description":"OpenAPI 3.1.0 JSON document","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"sv_live_<prefix>.<secret> or sv_test_<prefix>.<secret>","description":"Pass your Servunio API key in the `Authorization: Bearer <key>` header."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key","description":"Alternative to Bearer auth — pass your Servunio API key in the `X-API-Key` header."}},"schemas":{"ExecutionStatus":{"type":"string","enum":["CREATED","AWAITING_CONFIRMATION","RUNNING","SUCCEEDED","FAILED","CANCELED"],"description":"Lifecycle state of a workflow execution."},"CapabilityContract":{"type":"object","required":["code","version","displayName","sideEffect","requiredIdentity","requiresConfirmation","status"],"properties":{"code":{"type":"string","description":"Dot-namespaced capability identifier.","example":"booking.create"},"version":{"type":"string","description":"Semantic version of this capability definition.","example":"1.0.0"},"displayName":{"type":"string","description":"Human-readable capability name.","example":"Create Appointment"},"description":{"type":"string","nullable":true,"description":"What this capability does."},"sideEffect":{"type":"boolean","description":"Whether execution produces an irreversible external side-effect (e.g. sends an email, creates a booking)."},"requiredIdentity":{"type":"boolean","description":"Whether a verified customer identity is required to execute this capability."},"requiresConfirmation":{"type":"boolean","description":"Whether execution pauses for explicit approval before completing."},"inputSchema":{"type":"object","nullable":true,"additionalProperties":true,"description":"JSON Schema describing the required `input` payload."},"outputSchema":{"type":"object","nullable":true,"additionalProperties":true,"description":"JSON Schema describing the `result` payload returned on completion."},"status":{"type":"string","enum":["DISABLED","SETUP_REQUIRED","TESTING","ACTIVE","SUSPENDED","RETIRED"],"description":"Activation status for this organisation."}}},"WorkflowExecution":{"type":"object","required":["executionId","status","requiresConfirmation"],"properties":{"executionId":{"type":"string","format":"uuid","description":"Unique identifier for this execution."},"status":{"$ref":"#/components/schemas/ExecutionStatus"},"result":{"type":"object","nullable":true,"additionalProperties":true,"description":"Output payload when status is `completed`."},"requiresConfirmation":{"type":"boolean","description":"Whether this execution is paused awaiting confirmation."}}},"PaginatedResponse":{"type":"object","required":["data","hasMore"],"properties":{"data":{"type":"array","items":{"type":"object","additionalProperties":true},"description":"Page of resource records."},"hasMore":{"type":"boolean","description":"Whether more records exist beyond this page."},"nextCursor":{"type":"string","nullable":true,"description":"Pass as `after` on the next request to fetch the following page. `null` when `hasMore` is false."}}},"ApiError":{"type":"object","required":["message"],"properties":{"code":{"type":"string","enum":["VALIDATION_ERROR","IDEMPOTENCY_KEY_REQUIRED","INSUFFICIENT_SCOPE","IDEMPOTENCY_CONFLICT","REQUEST_IN_PROGRESS","RESULT_PENDING_RECONCILIATION","INTEGRATION_UNAVAILABLE","NOT_FOUND"],"description":"Machine-readable error code."},"message":{"type":"string","description":"Human-readable error description."},"requiredScope":{"type":"string","description":"Present on `INSUFFICIENT_SCOPE` errors; the scope the credential must carry."}}},"IdempotencyConflict":{"type":"object","required":["message"],"properties":{"code":{"type":"string","enum":["IDEMPOTENCY_CONFLICT","REQUEST_IN_PROGRESS","RESULT_PENDING_RECONCILIATION"],"description":"Conflict type."},"message":{"type":"string","description":"Human-readable conflict description."}}}}}}