{
    "openapi": "3.1.0",
    "info": {
        "title": "Simplifi Platform API",
        "version": "1.1",
        "contact": {
            "email": "easy@simplifi.ro",
            "url": "https://www.simplifi.ro/developers"
        },
        "license": {
            "name": "Proprietary",
            "url": "https://www.simplifi.ro/"
        },
        "description": "Simplifi's Platform API lets your software send documents for **qualified\nelectronic signature** (eIDAS) and automate document workflows end to end.\nNew here? Start with the\n[Platform API overview](/publicapi/v1/docs/platform) for the guided tour;\nthis page is the full endpoint reference.\n\n## Two principals, one API\n\n**Send for signature** (company principal; the product name is *Sign with\nSimplifi*): your software acts as your\ncompany. You upload a PDF, add signers and send; each counterparty signs on\nthe Simplifi platform with their own account and qualified certificate, and\nyou collect the executed PDF. No enrollment or certificate management on your\nside. Lifecycle: create (`POST /publicapi/v1/documents`), add signers, place\nannotations, send, redirect the signer to the returned `signing_url`, track\nvia webhooks or polling, download the signed PDF.\n\n**User automation** (user principal): your software acts as a specific\nSimplifi user, with their consent. A person at your company who already has a\nSimplifi account and qualified certificate authorizes your application once\nvia OAuth; your software then holds an **offline token** for them and drives\ntheir normal document workflows machine-to-machine, including signing with\nthe user's own certificate by supplying their current authenticator (TOTP)\ncode. See **Access & tokens**.\n\nPick per call, or combine both in one integration.\n\n## Access and pricing\n\n**There is no API fee and nothing to apply for.** A company admin creates the\nAPI client in the platform's API Settings (for the company principal), or a\nuser consents once via OAuth (for user automation), and the API works. Usage\nbills per act through the same credits as the web application (envelopes,\nsignature packs, one-sided documents); the relevant endpoints return stable\n`insufficient_*_balance` errors when a balance runs out.\n\n## Authentication\n\n**Send for signature** calls use an OAuth2 **client_credentials** access token\nfrom Keycloak. Your `oauth_client_id` and `client_secret` come from the API\nsettings page in the Simplifi platform (company admin).\n\n**User automation** calls instead use per-user **offline tokens** minted\nthrough the shared public client `platform-api` (device grant, or\nauthorization code with PKCE, with the `offline_access` scope): the user\nconsents once, your software stores the offline (refresh) token and exchanges\nit for short-lived access tokens.\n\n## Response envelope\n\nEvery response is wrapped in `{ \"success\": 0|1, \"error\": [..], \"data\": .. }`.\nError responses carry stable machine codes in the `error` array.\n\n## Webhooks\n\nCompany-principal integrations can register webhook endpoints in API\nSettings. Events are POSTed with an\n`X-Simplifi-Signature: sha256={hmac}` header (HMAC-SHA256 of the raw JSON\nbody with your endpoint's `signing_secret`). Each section ends with a\n**Webhook events** entry that documents the outbound payloads.\n\n## Rate limits\n\nBudgets are per API identity (the token's subject), never per IP address, in\none-minute windows. Every authenticated response advertises the current\nbudget via `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset`\nheaders. Exceeding it returns `429 too_many_requests` with a `Retry-After`\nheader; a client that paces itself off `RateLimit-Remaining` never sees one.\nIntegration (service) tokens get 1800 requests per minute, end-user tokens\n600, and a heavy integrator's ceiling can be raised per OAuth client on\nrequest.\n\n## Versioning\n\nThe API is path-versioned: everything documented here lives under\n`/publicapi/v1`. Changes within v1 are additive (new endpoints, new optional\nfields, new webhook event types), so build clients that ignore unknown\nfields. Incompatible changes ship as a new version path with a migration\nwindow; deprecations are announced here before they take effect.\n\n## Need more?\n\nA deeper partner integration model, **Embedded Signing**, puts identity\nverification, qualified certificate issuance and PDF signing entirely inside\nyour product; signers never need a Simplifi account. Available on application\n(reviewed; subscription-based). Contact us to discuss a partnership.\n"
    },
    "servers": [
        {
            "url": "https://api.simplifi.ro",
            "description": "Production"
        },
        {
            "url": "https://api.dev.simplifi.ro",
            "description": "Development / sandbox"
        }
    ],
    "security": [
        {
            "integratorOAuth": []
        }
    ],
    "tags": [
        {
            "name": "Connectivity",
            "description": "**Common**: auth smoke test, entitlements and webhook connectivity for the company-principal (`client_credentials`) integration."
        },
        {
            "name": "Send for signature",
            "description": "**Send for signature** (delegated): send a PDF into the Simplifi platform and\nlet your end users sign it with their own Simplifi account (Simplifi handles\nidentity, the signing session and the qualified certificate). You receive the\nsign codes / signing URLs to redirect users, and document lifecycle webhooks.\n\nMost operations in this section are **dual-principal**: they also accept a\nPlatform API user token, in which case they act on the *user's* account\n(see the Platform API sections).\n"
        },
        {
            "name": "Access & tokens",
            "description": "**Platform API** (user-principal): your software acts as a specific Simplifi\nuser, on their own account, with their consent.\n\n### Getting access\n\n1. Nothing to buy or apply for: the Platform API needs **no subscription**\n   - usage bills per act through the user's normal credits. Calls return\n   **403 `platform_api_disabled`** if the surface is globally disabled,\n   **403 `access_not_enabled`** if the company's API access was suspended\n   by an administrator, and **402 `subscription_required`** if the token\n   carries no company context. Exception: `POST /signing/sign-hash` keeps\n   the Embedded gate (approval + subscription).\n2. The user consents **once** via OAuth on the shared public client\n   **`platform-api`** (no client secret) with the `offline_access` scope:\n   - **Device grant** - `POST {auth}/realms/Simplifi/protocol/openid-connect/auth/device`\n     with `client_id=platform-api&scope=openid offline_access`; send the user\n     to `verification_uri_complete`, then poll the token endpoint with\n     `grant_type=urn:ietf:params:oauth:grant-type:device_code`.\n   - or **Authorization code + PKCE** (browser redirect flow).\n3. Store the returned `refresh_token` - this is the **offline token**\n   (long-lived; survives the user's web sessions). Exchange it for\n   short-lived access tokens with `grant_type=refresh_token` and call the\n   API with `Authorization: Bearer {access_token}`.\n\n### Scope of a Platform API token\n\nCalls run **as the user**: they see the user's documents and sign with the\nuser's own certificate. The token is capped to the intersection of the\ncurated Platform API surface (documents + signing routes) and the user's\nown role permissions - anything else returns **403 `access_denied`**.\nCompany context is selected per request with the optional `x-role-uuid`\nheader (the user's role UUID in that company; omit for the personal\nworkspace - note the subscription gate requires a company context).\n\nThe endpoints in this tag let users list and revoke their own offline\ntokens, and let company admins oversee their members' tokens.\n"
        },
        {
            "name": "Documents",
            "description": "**Platform API** (user-principal): the user's normal document workflows,\nmachine-to-machine. The create / add-signers / annotations / send / get /\ndownload-file operations are documented under **Send for signature** and\naccept Platform API tokens too (acting as the user; `ownership` then\ndefaults to `personal`). This section adds the operations available\n**only** with a user token: list, statistics, draft update, reminders,\ncancel and delete/purge.\n"
        },
        {
            "name": "Signing",
            "description": "**Platform API** (user-principal): sign or reject a document **as the\nuser**, with their own qualified certificate. The signing session is keyed by the\nper-signer `sign_code` (returned in document detail / list responses) and\nconfirmed with the user's current authenticator (TOTP) code - the same\nstrong customer authentication the web app uses. Not callable with\nintegrator `client_credentials` tokens.\n"
        },
        {
            "name": "Retention",
            "description": "**Platform API** (company admin): per-company document retention policy.\nWhen set, PDF files of terminal documents (COMPLETED / REJECTED /\nCANCELLED) are hard-deleted N days after the terminal transition (metadata\nand the eIDAS audit trail are preserved; file downloads then return\n**410 `document_files_purged`**). Default: keep forever.\n"
        }
    ],
    "x-tagGroups": [
        {
            "name": "Getting started",
            "tags": [
                "Connectivity"
            ]
        },
        {
            "name": "Platform API",
            "tags": [
                "Send for signature",
                "Access & tokens",
                "Documents",
                "Signing",
                "Retention"
            ]
        }
    ],
    "paths": {
        "/publicapi/v1/csc/integrator/ping": {
            "get": {
                "tags": [
                    "Connectivity"
                ],
                "operationId": "integratorPing",
                "summary": "Auth smoke test",
                "description": "Verifies the client_credentials token resolves to your API client.",
                "responses": {
                    "200": {
                        "description": "Token valid.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "ok": {
                                                            "type": "boolean"
                                                        },
                                                        "api_client_uuid": {
                                                            "type": "string",
                                                            "format": "uuid"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    }
                }
            }
        },
        "/publicapi/v1/csc/integrator/entitlements": {
            "get": {
                "tags": [
                    "Connectivity"
                ],
                "operationId": "integratorEntitlements",
                "summary": "Subscription and allowance snapshot",
                "description": "Your company's current CSC API subscription state and remaining allowance per\ncategory.\n\nUse this for dashboards, monitoring and pre-flight checks. For per-call freshness\nprefer the `X-Simplifi-Allowance-*` response headers returned by the billable\nendpoints - they cost you nothing and are always current. **Poll this endpoint at\nmost hourly.**\n\nThis endpoint never returns 402/403 for a blocked account: it answers 200 with the\nper-surface gate status in `surfaces`, so it stays usable exactly when you need to\nfind out what is wrong. Note the legacy `api_calls_enabled` / `blocked_reason` pair\nkeeps Embedded (CSC) semantics for backward compatibility: `api_calls_enabled: false`\ndoes NOT mean Send for signature / Platform API calls are blocked - check\n`surfaces.platform` for those.\n\n`overdraft` is consumption already delivered that no active grant covers - sessions\nthat completed after your balance ran out. It is settled automatically against your\nnext purchase. `allowance.*_remaining` never goes below zero, so a non-zero\n`overdraft` is the only way to see how far past your balance you are.\n",
                "responses": {
                    "200": {
                        "description": "Current entitlement state.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "metering_mode": {
                                                            "type": "string",
                                                            "enum": [
                                                                "enforce",
                                                                "log_only",
                                                                "unmetered"
                                                            ],
                                                            "description": "Allowance is only enforced in `enforce`."
                                                        },
                                                        "api_calls_enabled": {
                                                            "type": "boolean",
                                                            "description": "Whether live Embedded Signing (CSC) calls would pass the access gate right now. Kept with embedded semantics for backward compatibility - prefer `surfaces`."
                                                        },
                                                        "blocked_reason": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "enum": [
                                                                "csc_api_disabled",
                                                                "access_not_enabled",
                                                                "subscription_required",
                                                                null
                                                            ]
                                                        },
                                                        "surfaces": {
                                                            "type": "object",
                                                            "description": "Gate status per API surface. `platform` covers Send for signature\nand the Platform API - no approval or subscription needed; only a\nglobal kill switch or an admin suspension blocks it. `embedded`\ncovers the Embedded Signing (CSC) endpoints - requires approved\nAPI access plus the API Access subscription.\n",
                                                            "properties": {
                                                                "platform": {
                                                                    "type": "object",
                                                                    "properties": {
                                                                        "enabled": {
                                                                            "type": "boolean"
                                                                        },
                                                                        "blocked_reason": {
                                                                            "type": [
                                                                                "string",
                                                                                "null"
                                                                            ],
                                                                            "enum": [
                                                                                "csc_api_disabled",
                                                                                "access_not_enabled",
                                                                                null
                                                                            ]
                                                                        }
                                                                    }
                                                                },
                                                                "embedded": {
                                                                    "type": "object",
                                                                    "properties": {
                                                                        "enabled": {
                                                                            "type": "boolean"
                                                                        },
                                                                        "blocked_reason": {
                                                                            "type": [
                                                                                "string",
                                                                                "null"
                                                                            ],
                                                                            "enum": [
                                                                                "csc_api_disabled",
                                                                                "access_not_enabled",
                                                                                "subscription_required",
                                                                                null
                                                                            ]
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        },
                                                        "subscription": {
                                                            "type": "object",
                                                            "properties": {
                                                                "active": {
                                                                    "type": "boolean"
                                                                },
                                                                "expires_at": {
                                                                    "type": [
                                                                        "string",
                                                                        "null"
                                                                    ],
                                                                    "format": "date-time",
                                                                    "description": "End of the currently paid period. Not an end date if the subscription auto-renews."
                                                                }
                                                            }
                                                        },
                                                        "allowance": {
                                                            "type": "object",
                                                            "properties": {
                                                                "enrollments_remaining": {
                                                                    "type": "integer"
                                                                },
                                                                "signatures_remaining": {
                                                                    "type": "integer"
                                                                },
                                                                "packs_remaining": {
                                                                    "type": "integer"
                                                                },
                                                                "simple_packs_remaining": {
                                                                    "type": "integer",
                                                                    "description": "`csc_api_simple_packs` - simple-signature sessions (`signature_kind: simple`)."
                                                                }
                                                            }
                                                        },
                                                        "overdraft": {
                                                            "type": "object",
                                                            "description": "Units consumed beyond the balance, per category. Zero while in credit.",
                                                            "properties": {
                                                                "enrollments": {
                                                                    "type": "integer"
                                                                },
                                                                "signatures": {
                                                                    "type": "integer"
                                                                },
                                                                "packs": {
                                                                    "type": "integer"
                                                                },
                                                                "simple_packs": {
                                                                    "type": "integer"
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    }
                }
            }
        },
        "/publicapi/v1/csc/integrator/webhooks/test": {
            "post": {
                "tags": [
                    "Connectivity"
                ],
                "operationId": "webhookTest",
                "summary": "Send webhook.test to all enabled endpoints",
                "description": "Dispatches a `webhook.test` event to every enabled webhook endpoint configured\nfor your API client. Use it to verify connectivity and your HMAC verification.\n",
                "responses": {
                    "200": {
                        "description": "Test events dispatched.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "ok": {
                                                            "type": "boolean"
                                                        },
                                                        "message": {
                                                            "type": "string"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    }
                }
            }
        },
        "/publicapi/v1/csc/integrator/~webhook-events": {
            "get": {
                "tags": [
                    "Connectivity"
                ],
                "operationId": "connectivityWebhookEvents",
                "x-webhook-catalog": true,
                "summary": "Webhook events",
                "description": "**Documentation only** - not a callable route. Connectivity test events POSTed\nto your configured webhook endpoint(s). Trigger a delivery with\n`POST /integrator/webhooks/test`.\n",
                "responses": {
                    "501": {
                        "description": "Not callable; documents outbound webhook payloads only."
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error4xx"
                    }
                },
                "callbacks": {
                    "webhook.test": {
                        "$ref": "#/components/callbacks/WebhookTestEvent"
                    }
                }
            }
        },
        "/publicapi/v1/csc/integrator/~alert-webhook-events": {
            "get": {
                "tags": [
                    "Connectivity"
                ],
                "operationId": "alertWebhookEvents",
                "x-webhook-catalog": true,
                "summary": "Allowance & subscription alert events",
                "description": "**Documentation only** - not a callable route. Account-level alert events\nPOSTed to webhook endpoints subscribed to them. Emitted when a credit\nbalance crosses the warning threshold configured in the company's alert\nsettings (`allowance.low`), reaches zero (`allowance.exhausted`), when\nthe CSC API access subscription approaches its expiry\n(`subscription.at_risk`, with a `reason` explaining why it needs\nattention - including a plain renewal heads-up), and when access has\nlapsed and calls are being refused (`subscription.lapsed`).\n\nEach alert fires once per threshold crossing and re-arms when the\nbalance recovers (top-up / renewal). The same alerts can also be\ndelivered by email and SMS - recipients and thresholds are managed by\nyour company admin in the app's API settings.\n",
                "responses": {
                    "501": {
                        "description": "Not callable; documents outbound webhook payloads only."
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error4xx"
                    }
                },
                "callbacks": {
                    "allowance.low": {
                        "$ref": "#/components/callbacks/AllowanceLowEvent"
                    },
                    "allowance.exhausted": {
                        "$ref": "#/components/callbacks/AllowanceExhaustedEvent"
                    },
                    "subscription.at_risk": {
                        "$ref": "#/components/callbacks/SubscriptionAtRiskEvent"
                    },
                    "subscription.lapsed": {
                        "$ref": "#/components/callbacks/SubscriptionLapsedEvent"
                    }
                }
            }
        },
        "/publicapi/v1/documents": {
            "post": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "createDocument",
                "summary": "Create a draft document",
                "description": "Upload a PDF and create a DRAFT document owned by your company (it appears\nunder the company's Sent documents). Integrators send the PDF as base64 in a\nJSON body (`pdf_base64`); `ownership` defaults to `company`.\n\nThen add signers, place signature annotations and send (see the other\noperations below) - the same multi-step flow an end user performs in the UI.\n\nOptionally set `return_url` to an allowlisted redirect URI (same list as\nenrollment `redirect_uri`). After the signer completes or rejects the signing session,\nthe signing API responses include a signed `redirect_url` your web app can\nnavigate to (HMAC verified with your OAuth `client_secret`).\n\n**Dual-principal**: also callable with a Platform API user token - the\ndraft is then created by the user (`ownership` defaults to `personal`;\n`return_url` is integrator-only). A `multipart/form-data` variant is\naccepted too (part `file` with the PDF plus the same scalar fields).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "name",
                                    "signature_level",
                                    "pdf_base64"
                                ],
                                "properties": {
                                    "name": {
                                        "type": "string",
                                        "examples": [
                                            "Employment contract"
                                        ]
                                    },
                                    "signature_level": {
                                        "type": "string",
                                        "enum": [
                                            "QUALIFIED",
                                            "ADVANCED",
                                            "SIMPLE"
                                        ]
                                    },
                                    "pdf_base64": {
                                        "type": "string",
                                        "description": "Base64-encoded PDF bytes."
                                    },
                                    "file_name": {
                                        "type": "string",
                                        "examples": [
                                            "contract.pdf"
                                        ]
                                    },
                                    "ownership": {
                                        "type": "string",
                                        "enum": [
                                            "company",
                                            "personal"
                                        ],
                                        "default": "company"
                                    },
                                    "expires_at": {
                                        "type": "string",
                                        "format": "date-time"
                                    },
                                    "return_url": {
                                        "type": "string",
                                        "format": "uri",
                                        "description": "Optional. Must match a redirect URI registered for your API client.\nWhen set, sign/reject signing session responses (and guest status polling when\ncomplete) include a signed `redirect_url` back to this address.\n\nFor packs (multiple documents sharing a `document_group_uuid`),\n`return_url` is stored per document but a pack is signed in one\nsigning session, so only one redirect happens: it uses the `return_url` of the\nfirst signed pack member in group order. Set the same `return_url` on\nevery member for predictable behavior.\n"
                                    },
                                    "document_group_uuid": {
                                        "type": "string",
                                        "format": "uuid",
                                        "description": "Optional. Join an existing pack: pass the `document_group_uuid` returned when the first document was created. All members must be DRAFT with the same owner (and company), and the group must not be locked or at its member limit. When omitted, a fresh `document_group_uuid` is assigned - every document belongs to a group; a single document is simply a group of one.\n"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Draft created (carries the document `uuid` and its `document_group_uuid`).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "uuid": {
                                                            "type": "string",
                                                            "format": "uuid"
                                                        },
                                                        "document_group_uuid": {
                                                            "type": "string",
                                                            "format": "uuid",
                                                            "description": "The pack this draft belongs to (the one you passed, or a freshly assigned one). Pass it on the next `POST /documents` to build a pack."
                                                        },
                                                        "lifecycle": {
                                                            "type": "string",
                                                            "examples": [
                                                                "DRAFT"
                                                            ]
                                                        },
                                                        "name": {
                                                            "type": "string"
                                                        },
                                                        "expires_at": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "format": "date-time"
                                                        },
                                                        "ownership": {
                                                            "type": "string",
                                                            "enum": [
                                                                "company",
                                                                "personal"
                                                            ]
                                                        },
                                                        "cc_notification_emails": {
                                                            "type": "array",
                                                            "items": {
                                                                "type": "string",
                                                                "format": "email"
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "422": {
                        "description": "`name_required`, `signature_level_required`, `invalid_signature_level`, `file_required`, `invalid_pdf_base64`, `invalid_pdf` (the file is not a structurally valid PDF and could not be losslessly repaired; `data.reason` is `unparseable_pdf`, `unparseable_signed_pdf` - digitally signed files are never rewritten: ones the signing engine can read are accepted unchanged, damaged or encrypted ones rejected - or `password_protected_pdf` - the file requires an open password; permissions-only encryption is decrypted automatically and accepted), `invalid_ownership`, `invalid_return_url`, `document_group_invalid`, `document_group_locked`, `document_group_not_all_draft`, `document_group_max_members`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            },
            "get": {
                "tags": [
                    "Documents"
                ],
                "operationId": "listDocuments",
                "summary": "List documents",
                "description": "List the documents visible to the acting principal, filtered and\npaginated. With a Platform API user token this is the user's own inbox\nand sent list - the same data the web app shows.\n\nThe response carries the document array in `data` and a top-level\n`pagination` object (`{ page, per_page, total, total_pages }`). Owner\nrows include the document `uuid`; rows where the acting user is a signer\ninclude their `sign_code` for the signing session endpoints.\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    },
                    {
                        "name": "scope",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "default": "all_related",
                            "enum": [
                                "all_related",
                                "needs_my_signature",
                                "signed_by_me",
                                "rejected_by_me",
                                "waiting_for_others",
                                "drafts",
                                "completed_sent",
                                "cancelled_or_rejected_sent"
                            ]
                        }
                    },
                    {
                        "name": "envelope_ownership",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "personal",
                                "company",
                                "all"
                            ],
                            "default": "personal"
                        }
                    },
                    {
                        "name": "lifecycle",
                        "in": "query",
                        "description": "Comma-separated lifecycle filter (`DRAFT,PENDING,COMPLETED,REJECTED,CANCELLED,EXPIRED`).",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "action_required",
                        "in": "query",
                        "description": "Comma-separated; only with `scope=all_related`: `needs_my_signature`, `waiting_for_others` (or boolean shortcuts).",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "signers",
                        "in": "query",
                        "description": "Comma-separated signer emails (OR match, max 50).",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "verification_status",
                        "in": "query",
                        "description": "Comma-separated guest identity-verification filter (OR match): `in_progress`, `declined`, `failed`. Matches documents having at least one guest signer whose verification is in any of the requested states.",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "from",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "to",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "format": "date"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "default": "date_added",
                            "enum": [
                                "date_added",
                                "sent_at",
                                "completed_at",
                                "expires_at",
                                "name",
                                "size_bytes",
                                "lifecycle",
                                "owner_name",
                                "action_required"
                            ]
                        }
                    },
                    {
                        "name": "order",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "ASC",
                                "DESC"
                            ],
                            "default": "DESC"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Page of document summaries (plus top-level `pagination`).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/PlatformDocumentSummary"
                                                    }
                                                },
                                                "pagination": {
                                                    "$ref": "#/components/schemas/Pagination"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "422": {
                        "description": "`invalid_scope`, `invalid_sort_field`, `invalid_order`, `invalid_envelope_ownership`, `invalid_lifecycle`, `invalid_signers`, `invalid_verification_status`, `invalid_action_required`, `invalid_action_required_scope`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/statistics": {
            "get": {
                "tags": [
                    "Documents"
                ],
                "operationId": "getDocumentStatistics",
                "summary": "Dashboard statistics",
                "description": "Aggregate counters for the acting principal's documents - what the web\napp's dashboard tiles show: documents needing the user's signature,\ndocuments waiting for others, completions and signatures over the last\n30 days.\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    },
                    {
                        "name": "envelope_ownership",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "personal",
                                "company",
                                "all"
                            ],
                            "default": "personal"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Statistics.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "$ref": "#/components/schemas/PlatformDocumentStatistics"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "422": {
                        "description": "`invalid_envelope_ownership`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/signers": {
            "post": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "addDocumentSigners",
                "summary": "Add signers",
                "description": "Add one or more signers to a DRAFT document. For each SIGNATURE signer you\nchoose the `invitation_type`: how the end user is onboarded/authenticated for\nthe signing session, and optionally the `signature_kind` (`qualified` default, or\n`simple` for a no-IDV simple electronic signature - see\n`SignWithSimplifiSignerInput`).\n\nThe signer list is a **full replace** - existing signers are removed\nfirst. `signing_order` sequences the groups (lower signs first);\nsigners sharing an order and `parallel_group` may sign in parallel.\n\n**Dual-principal**: also callable with a Platform API user token\n(owner-only).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "signers"
                                ],
                                "properties": {
                                    "signers": {
                                        "type": "array",
                                        "items": {
                                            "$ref": "#/components/schemas/SignWithSimplifiSignerInput"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Signers added.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "422": {
                        "description": "`invalid_signer_email` (malformed address - rejected before any signer is replaced), `invalid_invitation_type`, `invalid_signature_kind`, `signature_kind_requires_signature_type` (simple + `signing_type: NONE`), `document_group_pack_signature_kind_mixed` (same email with different kinds across pack members) and other validation codes",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/annotations": {
            "post": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "setDocumentAnnotations",
                "summary": "Place signature annotations",
                "description": "Set the signature/seal placement annotations on the DRAFT document. Each\nannotation binds a signer `email` to a rectangle on a page. Full replace\nof the existing annotation set.\n\n**Dual-principal**: also callable with a Platform API user token\n(owner-only).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "annotations"
                                ],
                                "properties": {
                                    "annotations": {
                                        "type": "array",
                                        "items": {
                                            "$ref": "#/components/schemas/SignWithSimplifiAnnotation"
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Annotations stored.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "422": {
                        "description": "`annotations_required`, `invalid_annotations_json`, `invalid_annotation`, `invalid_annotation_type`, `invalid_annotation_email` (malformed address), `invalid_signature_placement` (nonexistent page, negative coordinates, or a box outside the page - `data.reason` names the violation, validated against the real PDF page dimensions), `document_not_draft`, `document_group_locked`, `self_signature_request_conflict`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/send": {
            "post": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "sendDocument",
                "summary": "Send the document for signing",
                "description": "Transition the document to PENDING and invite the first signer group. Each\nsigner receives an invitation email; you can also redirect users directly\nusing the per-signer `sign_code` / `signing_url` returned by\n`GET /publicapi/v1/documents/{uuid}`.\n\n**Dual-principal**: also callable with a Platform API user token\n(owner-only). Multi-document packs are sent with the group send endpoint\n(`use_document_group_send` is returned otherwise).\n\nWhen the document has `signature_kind: simple` signers, send is gated:\nthe sender's account must hold at least one simple-signature envelope\ncredit (**409 `insufficient_simple_signature_envelope_balance`**) and\nthe platform seal must be configured\n(**422 `simple_signature_seal_not_configured`**). The actual debit is\none credit per pack, charged at completion.\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Document sent.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "409": {
                        "description": "`insufficient_simple_signature_envelope_balance` (`data.shortfall`)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Validation codes - send is the final coherence gate: `signer_required`, `signature_annotation_required`, `invalid_signer_email` (a signer address that cannot receive the invitation), `annotation_signer_mismatch` (a SIGNATURE annotation bound to an email that is not a signer), `invalid_pdf` (the stored file cannot be processed even after lossless repair; `data.reason` is `unparseable_document_file` or `password_protected_pdf`), `document_file_missing` (the stored file was purged or is missing), `seal_not_allowed_for_simple_signer`, `simple_signature_seal_not_configured`, `simple_signature_seal_invalid`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}": {
            "get": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "getDocument",
                "summary": "Get document status (poll) - returns the whole pack",
                "description": "Read the lifecycle status and per-signer status. The response is the **pack view**: `data` carries `document_group_uuid`, `sent_at`, `member_count`, `current_document_uuid` (the uuid you requested) and a `documents` array with the full detail of every pack member (`is_current` marks the requested one). A standalone document is simply a pack of one - same shape, `member_count: 1`.\n\nFor documents your integration created, each signer entry also includes its `sign_code` and a ready-to-use `signing_url` for redirecting the end user.\n\n**Dual-principal**: also callable with a Platform API user token (owner-only view; signers use the signing session endpoints instead).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Pack detail (the requested document plus its group siblings).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "$ref": "#/components/schemas/SignWithSimplifiDocumentPack"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required`, `email_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "tags": [
                    "Documents"
                ],
                "operationId": "updateDocumentDraft",
                "summary": "Update draft metadata",
                "description": "Update a DRAFT document's metadata (owner only, user token only). Send\nat least one field; omitted fields are left unchanged. `expires_at: null`\nclears the expiry; `detach_from_document_group: true` (or\n`document_group_uuid: null`) detaches the document from its pack.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "name": {
                                        "type": "string"
                                    },
                                    "expires_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time"
                                    },
                                    "signature_level": {
                                        "type": "string",
                                        "enum": [
                                            "QUALIFIED",
                                            "ADVANCED",
                                            "SIMPLE"
                                        ]
                                    },
                                    "ownership": {
                                        "type": "string",
                                        "enum": [
                                            "personal",
                                            "company"
                                        ]
                                    },
                                    "detach_from_document_group": {
                                        "type": "boolean"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Updated metadata (`uuid`, `name`, `expires_at`, `signature_level`, `ownership`, `document_group_uuid`).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required`, `company_admin_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`document_not_draft`, `document_patch_required`, `name_required`, `invalid_signature_level`, `invalid_ownership`, `company_required_for_company_documents`, `document_group_locked`, `document_group_reassign_not_supported`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Documents"
                ],
                "operationId": "deleteDocument",
                "summary": "Delete (and optionally purge) a document",
                "description": "Delete always hides (soft delete, user token only); PDFs are additionally\n**hard-deleted from disk** (\"purged\") when the deleter was the last\nstakeholder with file access. Document metadata, signers and the audit\ntrail are always preserved; after a purge, file downloads return\n**410 `document_files_purged`**.\n\nOwner delete by lifecycle:\n- `PENDING`: rejected with **409 `cancel_required_before_delete`** - an\n  active signing session must be cancelled, not hidden while still signable.\n- `DRAFT`, `CANCELLED`, `EXPIRED`, `ERROR`: soft-deleted and files\n  auto-purged (signers have no file access in these states).\n- `COMPLETED`, `REJECTED`: soft-deleted; files auto-purge only when no\n  other participant still has access (e.g. the owner was the only\n  signer). Otherwise files are reclaimed later by the daily purge job,\n  once every participant has deleted or the company retention window\n  elapses.\n\n`mode=purge` (owner only) forces the purge of a `COMPLETED`/`REJECTED`\ndocument's files while other participants still have access (deliberate\ndestruction, e.g. an erasure request). A company admin deleting a\ncompany-owned document deletes it for the whole company side, including\nthe uploader.\n\nSigners deleting a received document only hide it from their own view\nand never trigger a purge. A pending, unanswered invite cannot be\ndeleted (**409 `reject_required_before_delete`**) - reject it instead.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    },
                    {
                        "name": "mode",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "purge"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Deleted (`data.uuid` echoes the document). Whether the files were also hard-deleted follows deterministically from the rules above; the response carries no purge indicator.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`access_denied`, `document_owner_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "`cancel_required_before_delete`, `cancel_required_before_purge`, `reject_required_before_delete`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`invalid_delete_mode`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/remind": {
            "post": {
                "tags": [
                    "Documents"
                ],
                "operationId": "remindDocumentSigner",
                "summary": "Remind a signer",
                "description": "Re-send the invitation email to one signer of a PENDING document (owner\nonly). The signer must currently be `INVITED` or `VIEWED`. Rate-limited:\nat most 3 reminders per signer per 24 hours, minimum 1 hour apart\n(**429 `document_remind_rate_limited`**, with `data.retry_after_seconds`).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "email"
                                ],
                                "properties": {
                                    "email": {
                                        "type": "string",
                                        "format": "email",
                                        "description": "The signer to remind."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Reminder queued.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`, `signer_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`invalid_document_lifecycle_for_reminder`, `valid_email_required`, `invalid_signer_status_for_reminder`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "`document_remind_rate_limited` (`data.retry_after_seconds`)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/cancel": {
            "post": {
                "tags": [
                    "Documents"
                ],
                "operationId": "cancelDocument",
                "summary": "Cancel a document",
                "description": "Cancel a DRAFT or PENDING document (owner only). Requires the acting\n**user's current authenticator (TOTP) code** - cancellation is a signed\nuser action, so it is effectively user-token only.\n\nCancelling a PENDING document emails a cancellation notice to every\nalready-invited party (invited/viewed/signed signers and CC\nnotification addresses); their pending signature requests become void.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "totp"
                                ],
                                "properties": {
                                    "totp": {
                                        "type": "string",
                                        "description": "The user's current 6-digit authenticator code."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Document cancelled.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`invalid_document_lifecycle_for_cancel`, `totp_code_required`, `totp_not_configured`, `invalid_totp`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/file": {
            "get": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "getDocumentFile",
                "summary": "Download the (signed) PDF",
                "description": "Download the current document PDF. Once the document is COMPLETED this is the\nfully-executed, signed PDF.\n\n**Dual-principal**: also callable with a Platform API user token\n(owner-only; a signer downloads via\n`GET /publicapi/v1/signing/{sign_code}/file` instead). Returns\n**410 `document_files_purged`** if the files were purged by retention or\nan explicit purge delete.\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "PDF bytes.",
                        "content": {
                            "application/pdf": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/audit-certificate": {
            "get": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "getDocumentAuditCertificate",
                "summary": "Download the Certificate of Completion",
                "description": "Download the sealed Certificate of Completion (audit certificate) for a\nCOMPLETED document: document identity and executed-file SHA-256, every\nsigner with signature kind and timestamps, and the captured evidence\ntimeline (views, consent, signatures, IP addresses as reported by\nCloudflare). The PDF is sealed with a qualified electronic seal of\nSIMPLIWORKS S.R.L., so any modification invalidates it.\n\nGenerated automatically at completion; if that attempt failed (e.g.\nsigning backend briefly down) this endpoint regenerates it on demand.\n\n**Dual-principal**: also callable with a Platform API user token\n(owner-only; a signer downloads via\n`GET /publicapi/v1/signing/{sign_code}/audit-certificate` instead).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "PDF bytes.",
                        "content": {
                            "application/pdf": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`, `audit_certificate_not_available`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`document_not_completed`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/{uuid}/csc-config": {
            "get": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "getDocumentCscConfig",
                "summary": "Export placements as a CSC API request (Developer mode)",
                "description": "Export the document's signature placements as ready-to-paste\n`POST /publicapi/v1/csc/signing-sessions` request skeletons - position\nsignatures visually in the web app, then reproduce the exact geometry\nfrom your own integration code.\n\nSources: owner-placed SIGNATURE annotations and each signer's draft\nplacement (the box a signer positioned but has not signed yet; cleared\non sign). SEAL annotations are excluded (not reproducible through a CSC\nsigning session) and ink images are never exported - supply your own\n`signatures[].data` or omit it for the typed-name fallback.\n\nCoordinates are returned unchanged: annotations and draft placements\nare already stored in the CSC coordinate system (PDF points, top-left\nviewer origin, 1-based page; rotation handled server-side). Values are\nrounded to 2 decimals.\n\nOne CSC session signs with one credential, so `data.csc_requests`\ncontains one skeleton per distinct signer email (placements without an\nassigned email are grouped under `signer_email: null`). The body is a\nskeleton by design: only geometry and `stamp_branding` are filled in;\nadd `flow`, `signer_id`, `return_url` and other session fields per the\nsigning-sessions documentation.\n\n**Dual-principal**: also callable with a Platform API user token\n(owner-only).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/DocumentUuid"
                    },
                    {
                        "name": "stamp_branding",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "simplifi",
                                "none",
                                "transparent",
                                "minimal"
                            ],
                            "default": "simplifi"
                        },
                        "description": "Branding value to embed in the exported skeletons."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "`data.coordinate_system` (contract, display verbatim), `data.document`\n(`uuid`, `name`, `pages[]` with per-page `width`/`height` in pt when the\nPDF is parseable), `data.placements[]` (`source`: `annotation` | `draft`,\n`signer_email`, `page`, `x`, `y`, `width`, `height`), `data.csc_requests[]`\n(`signer_email`, `method`, `url`, `body` - the request skeleton) and\n`data.notes[]` (caveats, display verbatim).\n",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`invalid_stamp_branding`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`no_placements_found` - the document has neither SIGNATURE annotations nor draft placements",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/verify/{certificate_uuid}": {
            "get": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "verifyAuditCertificate",
                "summary": "Verify a Certificate of Completion (public)",
                "description": "Public, unauthenticated verification of a Certificate of Completion by\nthe certificate id printed on the PDF and encoded in its QR code.\nResolves both certificate kinds, discriminated by `data.kind`:\n`document` (platform signing document certificates) and `csc_session`\n(CSC API signing-session certificates). Returns just enough to confirm\nthe certificate is genuine and no personal data. For `document`:\ncompletion time, signer count and signature kinds, and the SHA-256\nfingerprints of the executed and original files - compare\n`executed_file_sha256` with the hash of the signed document you hold.\nFor `csc_session`: session completion time, signature level, and the\nper-document SHA-256 pairs (reviewed content / signed result).\n\nUnknown, malformed and not-yet-issued ids all return the same\n`valid: false` 404 shape, so the endpoint cannot be used to probe which\ndocuments or sessions exist. Rate limited per client IP and per\ncertificate id (429 `rate_limited`).\n\nJSON-only: the human-facing verification page (the QR target,\n`{app base}/verify/{certificate_uuid}`) is built on top of this\nendpoint.\n",
                "security": [],
                "parameters": [
                    {
                        "name": "certificate_uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        },
                        "description": "Certificate ID printed on the Certificate of Completion."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Certificate is genuine.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "valid": {
                                                            "type": "boolean",
                                                            "description": "Always `true` on 200."
                                                        },
                                                        "kind": {
                                                            "type": "string",
                                                            "enum": [
                                                                "document",
                                                                "csc_session"
                                                            ],
                                                            "description": "Certificate kind - which of the two field sets below applies."
                                                        },
                                                        "certificate_uuid": {
                                                            "type": "string",
                                                            "format": "uuid"
                                                        },
                                                        "certificate_generated_at": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "format": "date-time",
                                                            "description": "Last (re)generation time of the certificate PDF."
                                                        },
                                                        "document_uuid": {
                                                            "type": "string",
                                                            "format": "uuid",
                                                            "description": "`kind=document` only."
                                                        },
                                                        "document_completed_at": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "format": "date-time",
                                                            "description": "`kind=document` only."
                                                        },
                                                        "signer_count": {
                                                            "type": "integer",
                                                            "description": "`kind=document` only."
                                                        },
                                                        "signature_kinds": {
                                                            "type": "object",
                                                            "description": "`kind=document` only. Signer count per signature kind.",
                                                            "properties": {
                                                                "qualified": {
                                                                    "type": "integer"
                                                                },
                                                                "simple": {
                                                                    "type": "integer"
                                                                }
                                                            }
                                                        },
                                                        "executed_file_sha256": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "description": "`kind=document` only. SHA-256 (hex) of the executed file; `null` once source files are purged by retention."
                                                        },
                                                        "original_file_sha256": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "description": "`kind=document` only. SHA-256 (hex) of the original uploaded file; `null` once purged."
                                                        },
                                                        "session_completed_at": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "format": "date-time",
                                                            "description": "`kind=csc_session` only."
                                                        },
                                                        "signature_level": {
                                                            "type": "string",
                                                            "enum": [
                                                                "SES"
                                                            ],
                                                            "description": "`kind=csc_session` only. Session certificates are issued for simple (SES) sessions."
                                                        },
                                                        "document_count": {
                                                            "type": "integer",
                                                            "description": "`kind=csc_session` only."
                                                        },
                                                        "documents": {
                                                            "type": "array",
                                                            "description": "`kind=csc_session` only. Per-document fingerprints, without labels (no PII).",
                                                            "items": {
                                                                "type": "object",
                                                                "properties": {
                                                                    "reviewed_content_sha256": {
                                                                        "type": [
                                                                            "string",
                                                                            "null"
                                                                        ],
                                                                        "description": "SHA-256 (hex) of the exact bytes presented for review."
                                                                    },
                                                                    "signed_file_sha256": {
                                                                        "type": [
                                                                            "string",
                                                                            "null"
                                                                        ],
                                                                        "description": "SHA-256 (hex) of the sealed output file; `null` once cleaned up from storage."
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`certificate_not_found` - unknown, malformed or not-yet-issued id; `data.valid` is `false`.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "`rate_limited`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/~webhook-events": {
            "get": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "signWithSimplifiWebhookEvents",
                "x-webhook-catalog": true,
                "summary": "Webhook events",
                "description": "**Documentation only** - not a callable route. Document lifecycle events for\nSign-with-Simplifi integrations POSTed to your configured webhook endpoint(s).\n",
                "responses": {
                    "501": {
                        "description": "Not callable; documents outbound webhook payloads only."
                    },
                    "4XX": {
                        "$ref": "#/components/responses/Error4xx"
                    }
                },
                "callbacks": {
                    "document.signer.signed": {
                        "$ref": "#/components/callbacks/DocumentSignerSignedEvent"
                    },
                    "document.completed": {
                        "$ref": "#/components/callbacks/DocumentCompletedEvent"
                    },
                    "document.rejected": {
                        "$ref": "#/components/callbacks/DocumentRejectedEvent"
                    }
                }
            }
        },
        "/publicapi/v1/signing/{sign_code}": {
            "get": {
                "tags": [
                    "Signing"
                ],
                "operationId": "getSignerCeremonyInfo",
                "summary": "Get signing session info (as signer)",
                "description": "The signer's view of a document (or pack) awaiting their signature,\nkeyed by their `sign_code`. Returns the documents with the signer's own\nplacement annotations, the signer roster with statuses, and\n`my_signer_info` for the acting user. Each document row (and the envelope top level, mirroring the current link's document) carries `audit_certificate_available` - same semantics as the owner detail: false means the Certificate of Completion will never exist (legacy completions). The authenticated user's email\nmust match the signer row (**403 `claim_required`** with a masked\n`invited_email_hint` otherwise). DRAFT documents return **404** to\nsigners.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/SignCode"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Signing session info (pack envelope with `documents[]`, `my_signer_info`, `current_sign_code`).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`claim_required` (`data.invited_email_hint` is a masked email)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "tags": [
                    "Signing"
                ],
                "operationId": "deleteAsSigner",
                "summary": "Delete a received document (as signer)",
                "description": "Signer-side counterpart of `DELETE /publicapi/v1/documents/{uuid}` for\nrecipients whose lists expose only `sign_code` (document `uuid` is an\nowner-only surface). Hides the document from the acting user's own\nlists by soft-deleting their visibility rows; the owner and other\nsigners keep access and this call never purges PDFs (files are\nreclaimed later by the purge job once no stakeholder is left).\n\nWhile the document is PENDING and the invite is still actionable\n(signer status `INVITED`/`VIEWED`), answers\n**409 `reject_required_before_delete`** - reject first, then delete.\nRequires an authenticated account matching the signer (invited email,\nbound role, or a succeeded claim); guest sign links cannot delete.\nRepeated calls succeed (idempotent).\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/SignCode"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Hidden from the caller's lists (`data.sign_code`).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`access_denied` (account does not match the signer)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`signer_not_found`, `document_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "`reject_required_before_delete`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/signing/{sign_code}/file": {
            "get": {
                "tags": [
                    "Signing"
                ],
                "operationId": "getSignerCeremonyFile",
                "summary": "Download the PDF (as signer)",
                "description": "Download the current document PDF from the signer's perspective. A\nsigner in status `INVITED` is automatically moved to `VIEWED` on first\ndownload.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/SignCode"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "PDF bytes.",
                        "content": {
                            "application/pdf": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "404": {
                        "description": "Signer or document not found.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "410": {
                        "description": "`document_files_purged`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Document lifecycle or signer status does not allow viewing.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/signing/{sign_code}/audit-certificate": {
            "get": {
                "tags": [
                    "Signing"
                ],
                "operationId": "getSignerAuditCertificate",
                "summary": "Download the Certificate of Completion (as signer)",
                "description": "Download the sealed Certificate of Completion for a COMPLETED document\nfrom the signer's perspective (same PDF the owner gets from\n`GET /publicapi/v1/documents/{uuid}/audit-certificate`). Guest signers\nuse `GET /publicapi/v1/signing-guest/{sign_code}/audit-certificate`\nwhile their completed-access window is open.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/SignCode"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "PDF bytes.",
                        "content": {
                            "application/pdf": {
                                "schema": {
                                    "type": "string",
                                    "format": "binary"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "404": {
                        "description": "Signer or document not found; `audit_certificate_not_available`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`document_not_completed`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/signing/{sign_code}/sign": {
            "post": {
                "tags": [
                    "Signing"
                ],
                "operationId": "signAsUser",
                "summary": "Sign (user's certificate + TOTP)",
                "description": "Sign the document **as the acting user**, with their own qualified\ncertificate, confirmed by their current authenticator (TOTP) code - the\nsame strong customer authentication the web app uses. The\n`signature_payload` placements must match the signer's annotations\n(count, type and coordinates).\n\nThe document must be PENDING, the signer `INVITED` or `VIEWED`, and it\nmust be the signer's turn per `signing_order` / `parallel_group`.\nBilling debits the acting role's existing signature entitlements (e.g.\n`one_sided_documents`) exactly like signing in the web app -\n**409 `insufficient_one_sided_document_balance`** on shortfall.\n\nFor documents created by a CSC integrator with a `return_url`, the\nresponse includes the signed `redirect_url` (see Send for signature).\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/SignCode"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "totp",
                                    "signature_payload"
                                ],
                                "properties": {
                                    "totp": {
                                        "type": "string",
                                        "description": "The user's current 6-digit authenticator code."
                                    },
                                    "signature_payload": {
                                        "type": "array",
                                        "description": "One entry per required annotation of this signer. Geometry\nis in PDF points with a top-left page origin (`x` right,\n`y` down) - same coordinate system as Embedded Signing\nplacements and Send for signature annotations.\n",
                                        "items": {
                                            "type": "object",
                                            "properties": {
                                                "type": {
                                                    "type": "string",
                                                    "enum": [
                                                        "SIGNATURE",
                                                        "SEAL"
                                                    ],
                                                    "default": "SIGNATURE"
                                                },
                                                "page": {
                                                    "type": "integer",
                                                    "minimum": 1,
                                                    "description": "1-based page number."
                                                },
                                                "x": {
                                                    "type": "number",
                                                    "description": "Left edge of the signature box, pt from the left page edge."
                                                },
                                                "y": {
                                                    "type": "number",
                                                    "description": "Top edge of the signature box, pt from the top page edge."
                                                },
                                                "width": {
                                                    "type": "number",
                                                    "description": "Box width in pt (recommended 133)."
                                                },
                                                "height": {
                                                    "type": "number",
                                                    "description": "Box height in pt (recommended 53)."
                                                },
                                                "stamp_branding": {
                                                    "type": "string",
                                                    "default": "simplifi"
                                                }
                                            }
                                        }
                                    },
                                    "timezone": {
                                        "type": "string",
                                        "description": "IANA timezone for the visible stamp date (default Europe/Bucharest)."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Signed (`data.sign_code`; `data.redirect_url` for integrator-originated documents).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`invalid_stamp_branding`, `invalid_timezone`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "Not authorized to sign this document.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Signer or document not found.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "`insufficient_one_sided_document_balance` (`data.shortfall`)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`totp_code_required`, `totp_not_configured`, `invalid_totp`, `signature_payload_annotation_count_mismatch`, `signature_payload_type_mismatch`, `invalid_signature_payload_type`, `invalid_signature_format`, `seal_not_allowed_for_prepaid_signer`, plus lifecycle / turn-order violations (e.g. it is not the signer's turn)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "`too_many_totp_attempts` - shared per-account TOTP lockout (5 wrong codes across any TOTP-gated operation locks the account's TOTP checks for 15 minutes). `data.retry_after_minutes` carries the wait.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/signing/{sign_code}/reject": {
            "post": {
                "tags": [
                    "Signing"
                ],
                "operationId": "rejectAsUser",
                "summary": "Reject (as signer)",
                "description": "Reject the document as the acting user (their signer row must be\n`INVITED` or `VIEWED` on a PENDING document). Also TOTP-confirmed. The\ndocument becomes REJECTED and the owner is notified (plus the\n`document.rejected` webhook for integrator-originated documents).\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/SignCode"
                    },
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "totp"
                                ],
                                "properties": {
                                    "totp": {
                                        "type": "string",
                                        "description": "The user's current 6-digit authenticator code."
                                    },
                                    "reason": {
                                        "type": "string",
                                        "description": "Optional rejection reason (stored and forwarded)."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Rejected (`data.document_uuid`; `data.redirect_url` for integrator-originated documents).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "Not authorized to reject this document.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Signer or document not found.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`totp_code_required`, `totp_not_configured`, `invalid_totp`, plus lifecycle / signer-status violations",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/account/roles": {
            "get": {
                "tags": [
                    "Access & tokens"
                ],
                "operationId": "listOwnRoles",
                "summary": "List my roles (source of x-role-uuid)",
                "description": "The authenticated user's roles with their UUIDs - this is where the\nvalue for the `x-role-uuid` company-context header comes from\n(`data.roles[].role_uuid` plus company and display fields). Pick the\nrole in the company whose subscription covers the API. Identity-gated:\nalways returns the caller's own roles; no `x-role-uuid` needed on this\ncall, and it works **before** a subscribed company context exists -\nunlike the rest of the surface it is not subscription-gated (402 here\nwould make the role UUID undiscoverable).\n\nWithout list query parameters the full `data.roles` array is returned.\nList mode (any of the parameters below) adds `pagination`.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer"
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "maximum": 100
                        }
                    },
                    {
                        "name": "search",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "company_name",
                                "role_code",
                                "role_name",
                                "short_form",
                                "is_personal"
                            ]
                        }
                    },
                    {
                        "name": "order",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "asc",
                                "desc"
                            ]
                        }
                    },
                    {
                        "name": "company_uuid",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "role_code",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "is_personal",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "0",
                                "1",
                                "true",
                                "false"
                            ]
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "`data.roles[]` with `role_uuid`; `pagination` in list mode.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "403": {
                        "description": "`platform_api_disabled` - the Platform API surface is globally disabled (no 402 here: this route is not subscription-gated).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Invalid list or filter parameters.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/platform/tokens": {
            "get": {
                "tags": [
                    "Access & tokens"
                ],
                "operationId": "listPlatformTokens",
                "summary": "List offline tokens",
                "description": "List the Keycloak **offline sessions** of the `platform-api` client -\ni.e. the offline tokens currently authorized. Without `role_uuid`, the\nacting user's own tokens are listed. With `role_uuid` (a team member's\nrole UUID), a **company admin** lists that member's tokens instead.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    },
                    {
                        "name": "role_uuid",
                        "in": "query",
                        "required": false,
                        "description": "Member role UUID - admin oversight of a team member's tokens.",
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Token list, most recently used first.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "tokens": {
                                                            "type": "array",
                                                            "items": {
                                                                "$ref": "#/components/schemas/PlatformOfflineToken"
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`company_context_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "403": {
                        "description": "`admin_role_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`member_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "`keycloak_sessions_unavailable`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "`keycloak_user_missing`, `keycloak_admin_not_configured`, `platform_api_client_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/platform/tokens/revoke": {
            "post": {
                "tags": [
                    "Access & tokens"
                ],
                "operationId": "revokePlatformToken",
                "summary": "Revoke an offline token",
                "description": "Revoke one offline session by its `session_id` (from the list response).\nThe stored offline refresh token stops working immediately; already\nissued access tokens expire naturally (minutes). Include `role_uuid` for\nthe company-admin variant (revoking a member's token). Revocation is\nrecorded as a security event.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "session_id"
                                ],
                                "properties": {
                                    "session_id": {
                                        "type": "string",
                                        "description": "Offline session id from the list endpoint."
                                    },
                                    "role_uuid": {
                                        "type": "string",
                                        "format": "uuid",
                                        "description": "Member role UUID (admin revoke)."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Revoked (`data.status: revoked`, `data.session_id`).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`session_id_required`, `company_context_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "403": {
                        "description": "`admin_role_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`member_not_found`, `token_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "502": {
                        "description": "`keycloak_revoke_failed`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "`keycloak_admin_not_configured`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/platform/retention": {
            "get": {
                "tags": [
                    "Retention"
                ],
                "operationId": "getRetentionPolicy",
                "summary": "Get retention policy",
                "description": "Read the company's document retention policy (company admin only;\nselect the company with `x-role-uuid`). `retention_days: null` means\nkeep forever (the default when no policy was ever set).\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Current policy.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "$ref": "#/components/schemas/PlatformRetentionPolicy"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`company_context_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "403": {
                        "description": "`admin_role_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            },
            "put": {
                "tags": [
                    "Retention"
                ],
                "operationId": "setRetentionPolicy",
                "summary": "Set or clear retention policy",
                "description": "Set `retention_days` to 1-3650 to hard-delete the PDF files of terminal\ndocuments (COMPLETED / REJECTED / CANCELLED) that many days after the\nterminal transition, or to `null` to keep files forever. Metadata and\nthe audit trail are always preserved; purged file downloads return\n**410 `document_files_purged`**. Changes are recorded as a security\nevent.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/RoleUuidHeader"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "retention_days"
                                ],
                                "properties": {
                                    "retention_days": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "minimum": 1,
                                        "maximum": 3650,
                                        "description": "Days to keep terminal documents' files; null = keep forever."
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Policy after the write.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "$ref": "#/components/schemas/PlatformRetentionPolicy"
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`company_context_required`, `retention_days_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "403": {
                        "description": "`admin_role_required`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`invalid_retention_days`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/documents/groups/{document_group_uuid}/send": {
            "post": {
                "tags": [
                    "Send for signature"
                ],
                "operationId": "sendDocumentGroup",
                "summary": "Send a pack (all group members, atomically)",
                "description": "Send every document in the group in one transaction: all members are validated and moved out of DRAFT together, invitations go out per signer, and per-document results are returned. If any member fails validation the whole send rolls back (`422 document_group_send_failed` with a `failures` array naming the offending documents).\n\nSafe to call again: a fully sent group answers `already_sent: true` with every member marked `skipped`.\n\n**Dual-principal**: integrator token or Platform API user token (owner/company-admin rights over every member required).\n",
                "security": [
                    {
                        "integratorOAuth": []
                    },
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "document_group_uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        },
                        "description": "The group uuid returned at document creation."
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Per-document send results (or `already_sent: true` for a fully sent group).",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "document_group_uuid": {
                                                            "type": "string",
                                                            "format": "uuid"
                                                        },
                                                        "sent_at": {
                                                            "type": [
                                                                "string",
                                                                "null"
                                                            ],
                                                            "format": "date-time"
                                                        },
                                                        "already_sent": {
                                                            "type": "boolean",
                                                            "description": "Present (true) when the group was already fully sent; members are then all `skipped`."
                                                        },
                                                        "documents": {
                                                            "type": "array",
                                                            "items": {
                                                                "type": "object",
                                                                "properties": {
                                                                    "uuid": {
                                                                        "type": "string",
                                                                        "format": "uuid"
                                                                    },
                                                                    "lifecycle_status": {
                                                                        "type": "string",
                                                                        "examples": [
                                                                            "PENDING"
                                                                        ]
                                                                    },
                                                                    "skipped": {
                                                                        "type": "boolean"
                                                                    },
                                                                    "reason": {
                                                                        "type": [
                                                                            "string",
                                                                            "null"
                                                                        ],
                                                                        "examples": [
                                                                            "solo_complete"
                                                                        ]
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "403": {
                        "description": "`document_owner_required` - the acting principal must own (or company-admin) every member.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "`document_group_invalid` (unknown group), `document_not_found` (a member is not visible to you)",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`document_group_invalid` (malformed uuid), pack invitation-rule violations (`document_group_pack_invitation_invalid` etc., with `data.invitation_violations`), or `document_group_send_failed` with `data.failures[{uuid, error}]` - per-member validation errors, e.g. `signer_required`, `signature_annotation_required`, `invalid_signer_email`, `annotation_signer_mismatch`, `invalid_pdf`, `document_file_missing`, `insufficient_prepaid_envelope_balance`. When the failing member's error is an entitlement balance code (`insufficient_prepaid_envelope_balance`, `insufficient_sponsored_signing_invitation_balance`, `insufficient_simple_signature_envelope_balance`), `data` additionally carries `shortfall` (integer - units the whole pack still needs beyond the balance holder's remaining), `balance_entitlement` (the entitlement code to top up), and `balance_holder` (`sender` for prepaid/sponsored, `document_owner` for simple envelopes - whose account needs the credits). The whole send rolls back; nothing is partially sent.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/publicapi/v1/signing/pack/{document_group_uuid}/sign": {
            "post": {
                "tags": [
                    "Signing"
                ],
                "operationId": "signPackAsUser",
                "summary": "Sign a pack (one TOTP for all members)",
                "description": "Sign every pack member the authenticated user is currently allowed to sign, in one call, with **one TOTP code for the whole pack** and a shared signature timestamp. There is no per-document code cost: a 9-document pack needs a single authenticator code.\n\nTolerant by design: members that are already signed, not the user's turn, or not pending are reported `skipped`, not failed - safe to retry to finish a partial run. The TOTP challenge is only required when at least one qualified act (personal signature or company seal) is being applied; simple-signature-only packs skip it.\n\nEach entry pairs the member's `sign_code` with the same `signature_payload` shape used by the single-document sign operation.\n",
                "security": [
                    {
                        "platformUserOAuth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "document_group_uuid",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        },
                        "description": "The pack to sign (see `document_group_uuid` on document detail)."
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "documents"
                                ],
                                "properties": {
                                    "documents": {
                                        "type": "array",
                                        "minItems": 1,
                                        "description": "One entry per pack member to sign.",
                                        "items": {
                                            "type": "object",
                                            "required": [
                                                "sign_code",
                                                "signature_payload"
                                            ],
                                            "properties": {
                                                "sign_code": {
                                                    "type": "string"
                                                },
                                                "signature_payload": {
                                                    "type": "array",
                                                    "description": "Same shape as the single-document sign operation (placements matching the signer's annotations).",
                                                    "items": {
                                                        "type": "object"
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    "totp": {
                                        "type": "string",
                                        "description": "The user's current 6-digit authenticator code. Required when at least one qualified signature or seal is applied; one code authorizes the entire pack.",
                                        "examples": [
                                            "123456"
                                        ]
                                    },
                                    "timezone": {
                                        "type": "string",
                                        "description": "Optional IANA timezone for the visible stamp timestamp (one instant shared by the whole pack).",
                                        "examples": [
                                            "Europe/Bucharest"
                                        ]
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "Per-document results. `skipped` members do not fail the call; retry later to finish.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "allOf": [
                                        {
                                            "$ref": "#/components/schemas/Envelope"
                                        },
                                        {
                                            "type": "object",
                                            "properties": {
                                                "data": {
                                                    "type": "object",
                                                    "properties": {
                                                        "document_group_uuid": {
                                                            "type": "string",
                                                            "format": "uuid"
                                                        },
                                                        "summary": {
                                                            "type": "object",
                                                            "properties": {
                                                                "requested": {
                                                                    "type": "integer"
                                                                },
                                                                "signed": {
                                                                    "type": "integer"
                                                                },
                                                                "skipped": {
                                                                    "type": "integer"
                                                                },
                                                                "failed": {
                                                                    "type": "integer"
                                                                }
                                                            }
                                                        },
                                                        "documents": {
                                                            "type": "array",
                                                            "items": {
                                                                "type": "object",
                                                                "properties": {
                                                                    "sign_code": {
                                                                        "type": "string"
                                                                    },
                                                                    "document_uuid": {
                                                                        "type": [
                                                                            "string",
                                                                            "null"
                                                                        ],
                                                                        "format": "uuid"
                                                                    },
                                                                    "status": {
                                                                        "type": "string",
                                                                        "enum": [
                                                                            "signed",
                                                                            "skipped",
                                                                            "failed"
                                                                        ]
                                                                    },
                                                                    "reason": {
                                                                        "type": "string",
                                                                        "description": "On skipped/failed only: e.g. `already_signed`, `not_your_turn`, `not_in_pack`, `signer_not_found`, `signature_payload_required`."
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "`invalid_timezone`, missing `document_group_uuid`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "401": {
                        "$ref": "#/components/responses/Unauthenticated"
                    },
                    "402": {
                        "$ref": "#/components/responses/SubscriptionRequired"
                    },
                    "404": {
                        "description": "`document_group_not_found`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "409": {
                        "description": "`insufficient_one_sided_document_balance` with `data.shortfall`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "`documents is required and must be a non-empty array`, `totp_code_required`, `totp_not_configured`, `invalid_totp`",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "`too_many_totp_attempts` - shared per-account TOTP lockout (5 wrong codes across any TOTP-gated operation locks the account's TOTP checks for 15 minutes). `data.retry_after_minutes` carries the wait.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorEnvelope"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "securitySchemes": {
            "integratorOAuth": {
                "type": "oauth2",
                "description": "Keycloak client_credentials. Token endpoint (production):\n`https://auth.simplifi.ro/realms/Simplifi/protocol/openid-connect/token`.\nDevelopment: `https://auth.dev.simplifi.ro/realms/Simplifi/protocol/openid-connect/token`.\n",
                "flows": {
                    "clientCredentials": {
                        "tokenUrl": "https://auth.simplifi.ro/realms/Simplifi/protocol/openid-connect/token",
                        "scopes": {}
                    }
                }
            },
            "platformUserOAuth": {
                "type": "oauth2",
                "description": "**Platform API** user tokens: the user consents once on the shared\npublic client `platform-api` (authorization code + PKCE, or the device\ngrant) with the `offline_access` scope; your software stores the\noffline (refresh) token and exchanges it for short-lived access tokens\nwith `grant_type=refresh_token`. Covered by the company's API Access\nsubscription - the same one that gates the whole integrator API\n(`402 subscription_required` otherwise). See the\n\"Access & tokens\" section.\n",
                "flows": {
                    "authorizationCode": {
                        "authorizationUrl": "https://auth.simplifi.ro/realms/Simplifi/protocol/openid-connect/auth",
                        "tokenUrl": "https://auth.simplifi.ro/realms/Simplifi/protocol/openid-connect/token",
                        "refreshUrl": "https://auth.simplifi.ro/realms/Simplifi/protocol/openid-connect/token",
                        "scopes": {
                            "openid": "OpenID Connect",
                            "offline_access": "Mint a long-lived offline (refresh) token"
                        }
                    }
                }
            }
        },
        "parameters": {
            "DocumentUuid": {
                "name": "uuid",
                "in": "path",
                "required": true,
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            },
            "SignCode": {
                "name": "sign_code",
                "in": "path",
                "required": true,
                "description": "The per-signer signing session code (from document detail / list responses).",
                "schema": {
                    "type": "string"
                }
            },
            "RoleUuidHeader": {
                "name": "x-role-uuid",
                "in": "header",
                "required": false,
                "description": "Platform API user tokens only: the user's role UUID selecting the\ncompany context to act in. Omit for the personal workspace (note the\nPlatform API subscription gate requires a company context).\n",
                "schema": {
                    "type": "string",
                    "format": "uuid"
                }
            }
        },
        "responses": {
            "Unauthenticated": {
                "description": "`integrator_unauthenticated` - missing/expired/invalid bearer token",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/ErrorEnvelope"
                        }
                    }
                }
            },
            "SubscriptionRequired": {
                "description": "`subscription_required` - the company's **API Access subscription**\n(required for Embedded Signing endpoints and `sign-hash`; Sign with\nSimplifi and the rest of the Platform API need no subscription) has no\nactive grant, or a Platform API request ran without a company context.\nRelated 403 codes from the same gate: `access_not_enabled` (Embedded\naccess not approved, or company API access suspended) and\n`platform_api_disabled` (Platform API surface globally disabled).\n",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/ErrorEnvelope"
                        }
                    }
                }
            },
            "Error4xx": {
                "description": "Request failed; `error` carries a stable machine-readable code.",
                "content": {
                    "application/json": {
                        "schema": {
                            "$ref": "#/components/schemas/ErrorEnvelope"
                        }
                    }
                }
            }
        },
        "callbacks": {
            "DocumentSignerSignedEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "A signer signed a Sign-with-Simplifi document",
                        "operationId": "onDocumentSignerSigned",
                        "description": "Fired for documents your integration created (origin tracked server-side).",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookDocumentSignerSigned"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "DocumentCompletedEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "A Sign-with-Simplifi document was fully executed",
                        "operationId": "onDocumentCompleted",
                        "description": "All signers have signed. Download the signed PDF from\n`GET /publicapi/v1/documents/{uuid}/file`.\n",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookDocumentCompleted"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "DocumentRejectedEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "A signer rejected a Sign-with-Simplifi document",
                        "operationId": "onDocumentRejected",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookDocumentRejected"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "WebhookTestEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "Connectivity test event",
                        "operationId": "onWebhookTest",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "allOf": [
                                            {
                                                "$ref": "#/components/schemas/WebhookEnvelope"
                                            },
                                            {
                                                "type": "object",
                                                "properties": {
                                                    "data": {
                                                        "type": "object",
                                                        "properties": {
                                                            "ok": {
                                                                "type": "boolean"
                                                            },
                                                            "message": {
                                                                "type": "string"
                                                            },
                                                            "timestamp": {
                                                                "type": "string",
                                                                "format": "date-time"
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        ]
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "AllowanceLowEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "Credit balance crossed the warning threshold",
                        "operationId": "onAllowanceLow",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookAllowanceAlert"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "AllowanceExhaustedEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "Credit balance reached zero",
                        "operationId": "onAllowanceExhausted",
                        "description": "In `enforce` metering mode, requests that consume this credit type are\nnow refused with 402 until the balance is topped up.\n",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookAllowanceAlert"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "SubscriptionAtRiskEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "CSC API access expires within the configured lookahead",
                        "operationId": "onSubscriptionAtRisk",
                        "description": "Fires ahead of the access expiry even for healthy auto-renewing\nsubscriptions (`reason: renewal_upcoming`); other reasons flag\nsomething to fix before access is interrupted. Re-fires if the\nreason changes (e.g. the renewal payment fails after the healthy\nheads-up already went out).\n",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookSubscriptionAlert"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            },
            "SubscriptionLapsedEvent": {
                "{$request.body#/url}": {
                    "post": {
                        "summary": "CSC API access has lapsed - calls are being refused",
                        "operationId": "onSubscriptionLapsed",
                        "requestBody": {
                            "content": {
                                "application/json": {
                                    "schema": {
                                        "$ref": "#/components/schemas/WebhookSubscriptionAlert"
                                    }
                                }
                            }
                        },
                        "responses": {
                            "200": {
                                "description": "Return any 2xx quickly; process async."
                            }
                        }
                    }
                }
            }
        },
        "schemas": {
            "Envelope": {
                "type": "object",
                "description": "Standard success envelope.",
                "properties": {
                    "success": {
                        "type": "integer",
                        "enum": [
                            1
                        ]
                    },
                    "error": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "description": "Empty on success."
                    },
                    "data": {
                        "description": "Endpoint-specific response payload; see each operation's response schema."
                    }
                }
            },
            "ErrorEnvelope": {
                "type": "object",
                "description": "Standard error envelope; `error` carries stable machine codes.",
                "properties": {
                    "success": {
                        "type": "integer",
                        "enum": [
                            0
                        ]
                    },
                    "error": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        },
                        "examples": [
                            [
                                "enrollment_not_found"
                            ]
                        ]
                    },
                    "data": {
                        "description": "Usually empty on errors; may carry endpoint-specific error context."
                    }
                }
            },
            "WebhookAllowanceAlert": {
                "description": "`allowance.low` / `allowance.exhausted` payload.",
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "level": {
                                        "type": "string",
                                        "enum": [
                                            "warning",
                                            "exhausted"
                                        ]
                                    },
                                    "entitlement_code": {
                                        "type": "string",
                                        "enum": [
                                            "csc_api_enrollments",
                                            "csc_api_signatures",
                                            "csc_api_packs",
                                            "csc_api_simple_packs"
                                        ]
                                    },
                                    "remaining": {
                                        "type": "integer",
                                        "description": "Credits left when the alert fired."
                                    },
                                    "threshold": {
                                        "type": [
                                            "integer",
                                            "null"
                                        ],
                                        "description": "The configured warning threshold; null on exhausted alerts when no warning threshold is set."
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "WebhookSubscriptionAlert": {
                "description": "`subscription.at_risk` / `subscription.lapsed` payload.",
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "data": {
                                "type": "object",
                                "properties": {
                                    "level": {
                                        "type": "string",
                                        "enum": [
                                            "warning",
                                            "exhausted"
                                        ],
                                        "description": "`warning` = at_risk, `exhausted` = lapsed."
                                    },
                                    "reason": {
                                        "type": "string",
                                        "enum": [
                                            "renewal_upcoming",
                                            "payment_failed",
                                            "cancellation_scheduled",
                                            "canceled",
                                            "no_subscription"
                                        ],
                                        "description": "Why the subscription needs attention. `renewal_upcoming` is a heads-up for a healthy auto-renewal."
                                    },
                                    "expires_at": {
                                        "type": [
                                            "string",
                                            "null"
                                        ],
                                        "format": "date-time",
                                        "description": "End of the current access grant; null on lapsed alerts (access already ended)."
                                    },
                                    "days_left": {
                                        "type": "integer",
                                        "description": "Whole days until expiry; 0 on lapsed alerts."
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "SignWithSimplifiSignerInput": {
                "type": "object",
                "required": [
                    "email"
                ],
                "properties": {
                    "email": {
                        "type": "string",
                        "format": "email"
                    },
                    "signing_type": {
                        "type": "string",
                        "enum": [
                            "SIGNATURE",
                            "NONE"
                        ],
                        "description": "SIGNATURE = must sign; NONE = receives a copy only. Inferred from annotations when omitted."
                    },
                    "invitation_type": {
                        "type": "string",
                        "enum": [
                            "standard_invitation",
                            "guest_invitation",
                            "sponsored_invitation"
                        ],
                        "default": "standard_invitation",
                        "description": "How the end user is onboarded for the signing session. `standard_invitation` -\nexisting/full Simplifi account; `guest_invitation` - lightweight guest\nsigning; `sponsored_invitation` - sponsored by your company's entitlements.\n"
                    },
                    "signature_kind": {
                        "type": "string",
                        "enum": [
                            "qualified",
                            "simple"
                        ],
                        "default": "qualified",
                        "description": "Per-signer signature kind. `qualified` (default): the signer's\npersonal qualified certificate after strong authentication.\n`simple`: a simple electronic signature - the guest signs from the\nemail link with no identity verification or OTP; the document is\nsigned with a qualified electronic seal applied by Simplifi on the\nsigner's behalf, with their identity in the signature Reason field.\nSimple signers require `signing_type: SIGNATURE` and never consume\nprepaid-envelope credits; instead the pack consumes one\n`simple_signature_envelopes` credit from the sender when it\ncompletes. Kinds can be mixed within a document.\n"
                    },
                    "signing_order": {
                        "type": "integer",
                        "default": 1,
                        "description": "Sequential signing groups (lower signs first)."
                    },
                    "parallel_group": {
                        "type": "integer",
                        "default": 0,
                        "description": "Signers sharing an order+group are invited in parallel."
                    },
                    "send_email": {
                        "type": "integer",
                        "enum": [
                            0,
                            1
                        ],
                        "default": 1
                    }
                }
            },
            "SignWithSimplifiAnnotation": {
                "type": "object",
                "required": [
                    "email",
                    "page",
                    "x",
                    "y"
                ],
                "description": "Geometry is in PDF points with a top-left page origin (`x` right, `y`\ndown), matching what a PDF viewer displays - same coordinate system as\nEmbedded Signing placements. Recommended box: 133 × 53 pt.\n",
                "properties": {
                    "type": {
                        "type": "string",
                        "enum": [
                            "SIGNATURE",
                            "SEAL"
                        ],
                        "default": "SIGNATURE"
                    },
                    "email": {
                        "type": "string",
                        "format": "email",
                        "description": "Signer this annotation belongs to."
                    },
                    "page": {
                        "type": "integer",
                        "description": "1-based page number."
                    },
                    "x": {
                        "type": "number",
                        "description": "Left edge of the signature box, pt from the left page edge."
                    },
                    "y": {
                        "type": "number",
                        "description": "Top edge of the signature box, pt from the top page edge."
                    },
                    "width": {
                        "type": "number",
                        "description": "Box width in pt (recommended 133)."
                    },
                    "height": {
                        "type": "number",
                        "description": "Box height in pt (recommended 53)."
                    },
                    "required": {
                        "type": "boolean",
                        "default": true,
                        "description": "Whether the signer must fill this placement. Defaults to true when omitted; only required annotations are shown to the signer in the signing session."
                    }
                }
            },
            "SignWithSimplifiDocumentDetail": {
                "type": "object",
                "properties": {
                    "uuid": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "lifecycle_status": {
                        "type": "string",
                        "enum": [
                            "DRAFT",
                            "PENDING",
                            "COMPLETED",
                            "REJECTED",
                            "CANCELLED"
                        ]
                    },
                    "signature_level": {
                        "type": "string"
                    },
                    "ownership": {
                        "type": "string",
                        "enum": [
                            "company",
                            "personal"
                        ]
                    },
                    "files_purged": {
                        "type": "boolean",
                        "description": "true when the PDF files were hard-deleted from disk (retention\npolicy, delete purge, or all-participants-deleted). Metadata and\nsigners remain; file downloads return 410 `document_files_purged`.\n"
                    },
                    "audit_certificate_available": {
                        "type": "boolean",
                        "description": "true when the sealed Certificate of Completion exists (or will be regenerated on demand) - fetch it with `GET /publicapi/v1/documents/{uuid}/audit-certificate`. false means it does not and will not exist, e.g. documents completed before audit certificates shipped - hide the download action.\n"
                    },
                    "return_url": {
                        "type": "string",
                        "format": "uri",
                        "description": "Echo of the integrator return URL when this document was created by your API client."
                    },
                    "signers": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "email": {
                                    "type": "string",
                                    "format": "email"
                                },
                                "status": {
                                    "type": "string"
                                },
                                "signing_type": {
                                    "type": "string"
                                },
                                "invitation_type": {
                                    "type": "string"
                                },
                                "signature_kind": {
                                    "type": "string",
                                    "enum": [
                                        "qualified",
                                        "simple"
                                    ],
                                    "description": "Signature kind requested for this signer (see add signers)."
                                },
                                "verification_status": {
                                    "type": "string",
                                    "enum": [
                                        "in_progress",
                                        "declined",
                                        "failed"
                                    ],
                                    "description": "Guest signers only; omitted unless identity verification is in a noteworthy state. Computed alongside `status` (which stays on the INVITED/VIEWED/SIGNED/REJECTED state machine). Decline reasons are never exposed on owner surfaces."
                                },
                                "verification_retryable": {
                                    "type": "boolean",
                                    "description": "Present with `verification_status` `declined` or `failed`: whether the guest can retry identity verification (same answer the guest's own retry screen shows)."
                                },
                                "sign_code": {
                                    "type": "string",
                                    "description": "Present for documents your integration created."
                                },
                                "signing_url": {
                                    "type": "string",
                                    "format": "uri",
                                    "description": "Ready-to-use end-user signing/redirect URL."
                                }
                            }
                        }
                    },
                    "is_current": {
                        "type": "boolean",
                        "description": "Present in pack views: true on the document whose uuid was requested."
                    }
                }
            },
            "Pagination": {
                "type": "object",
                "properties": {
                    "page": {
                        "type": "integer"
                    },
                    "per_page": {
                        "type": "integer"
                    },
                    "total": {
                        "type": "integer"
                    },
                    "total_pages": {
                        "type": "integer"
                    }
                }
            },
            "PlatformDocumentSummary": {
                "type": "object",
                "description": "One row of the document list. `uuid` is present on documents the acting\nprincipal owns; `sign_code` on documents where the acting user is a\nsigner. Timestamps are ISO 8601 UTC.\n",
                "properties": {
                    "uuid": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Owner rows only."
                    },
                    "sign_code": {
                        "type": "string",
                        "description": "Rows where the acting user is a signer."
                    },
                    "name": {
                        "type": "string"
                    },
                    "lifecycle": {
                        "type": "string",
                        "enum": [
                            "DRAFT",
                            "PENDING",
                            "COMPLETED",
                            "REJECTED",
                            "CANCELLED",
                            "EXPIRED"
                        ]
                    },
                    "signature_level": {
                        "type": "string",
                        "enum": [
                            "QUALIFIED",
                            "ADVANCED",
                            "SIMPLE"
                        ]
                    },
                    "ownership": {
                        "type": "string",
                        "enum": [
                            "personal",
                            "company"
                        ],
                        "description": "Owner rows only."
                    },
                    "owner_name": {
                        "type": "string"
                    },
                    "size_bytes": {
                        "type": "integer"
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "sent_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "completed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "expires_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "signer_status": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "signed": {
                                "type": "integer"
                            },
                            "viewed": {
                                "type": "integer"
                            },
                            "invited": {
                                "type": "integer"
                            },
                            "rejected": {
                                "type": "integer"
                            },
                            "draft": {
                                "type": "integer"
                            }
                        }
                    },
                    "verification_status": {
                        "type": "object",
                        "description": "Guest identity-verification breakdown. Present only when at least one guest signer is in a noteworthy verification state; counts of guest signers per category.",
                        "properties": {
                            "in_progress": {
                                "type": "integer"
                            },
                            "declined": {
                                "type": "integer"
                            },
                            "failed": {
                                "type": "integer"
                            }
                        }
                    },
                    "recipients": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "recipients_total": {
                        "type": "integer"
                    },
                    "action_required": {
                        "type": "array",
                        "description": "Only with `scope=all_related`.",
                        "items": {
                            "type": "string",
                            "enum": [
                                "needs_my_signature",
                                "waiting_for_others"
                            ]
                        }
                    }
                }
            },
            "PlatformDocumentStatistics": {
                "type": "object",
                "properties": {
                    "needs_my_signature": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "new_last_24h": {
                                "type": "integer"
                            }
                        }
                    },
                    "waiting_for_others": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "older_than_3_days": {
                                "type": "integer"
                            }
                        }
                    },
                    "completed_last_30_days": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "previous_30_days": {
                                "type": "integer"
                            }
                        }
                    },
                    "signed_last_30_days": {
                        "type": "object",
                        "properties": {
                            "total": {
                                "type": "integer"
                            },
                            "unique_senders": {
                                "type": "integer"
                            }
                        }
                    }
                }
            },
            "PlatformOfflineToken": {
                "type": "object",
                "properties": {
                    "session_id": {
                        "type": "string",
                        "description": "Keycloak offline session id (use to revoke)."
                    },
                    "ip": {
                        "type": "string"
                    },
                    "started_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "last_access_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    }
                }
            },
            "PlatformRetentionPolicy": {
                "type": "object",
                "properties": {
                    "retention_days": {
                        "type": [
                            "integer",
                            "null"
                        ],
                        "description": "1-3650, or null = keep forever."
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "When the policy was last changed (null if never set)."
                    }
                }
            },
            "WebhookDocumentSignerSigned": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "const": "document.signer.signed"
                            },
                            "data": {
                                "type": "object",
                                "properties": {
                                    "document_uuid": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "document_group_uuid": {
                                        "type": "string"
                                    },
                                    "signer_email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "signed_at": {
                                        "type": "string",
                                        "format": "date-time"
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "WebhookDocumentCompleted": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "const": "document.completed"
                            },
                            "data": {
                                "type": "object",
                                "properties": {
                                    "document_uuid": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "document_group_uuid": {
                                        "type": "string"
                                    },
                                    "status": {
                                        "type": "string",
                                        "const": "COMPLETED"
                                    },
                                    "completed_at": {
                                        "type": "string",
                                        "format": "date-time"
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "WebhookDocumentRejected": {
                "allOf": [
                    {
                        "$ref": "#/components/schemas/WebhookEnvelope"
                    },
                    {
                        "type": "object",
                        "properties": {
                            "type": {
                                "const": "document.rejected"
                            },
                            "data": {
                                "type": "object",
                                "properties": {
                                    "document_uuid": {
                                        "type": "string",
                                        "format": "uuid"
                                    },
                                    "document_group_uuid": {
                                        "type": "string"
                                    },
                                    "status": {
                                        "type": "string",
                                        "const": "REJECTED"
                                    },
                                    "rejected_by_email": {
                                        "type": "string",
                                        "format": "email"
                                    },
                                    "reason": {
                                        "type": "string"
                                    },
                                    "rejected_at": {
                                        "type": "string",
                                        "format": "date-time"
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "WebhookEnvelope": {
                "type": "object",
                "description": "Common webhook envelope. Verify `X-Simplifi-Signature: sha256={hmac}` -\nHMAC-SHA256 over the raw JSON body with your endpoint signing_secret.\nDeliveries are retried with exponential backoff (up to 8 attempts); use `id`\nfor idempotent processing (resends keep the same `id`).\n",
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid",
                        "description": "Delivery UUID - stable across retries and resends."
                    },
                    "type": {
                        "type": "string",
                        "examples": [
                            "application.verified"
                        ]
                    },
                    "created_at": {
                        "type": "string",
                        "format": "date-time"
                    },
                    "data": {
                        "type": "object"
                    }
                }
            },
            "SignWithSimplifiDocumentPack": {
                "type": "object",
                "description": "Pack (document group) wrapper returned by `GET /publicapi/v1/documents/{uuid}`. Every document belongs to a group; standalone documents are groups of one.\n",
                "properties": {
                    "document_group_uuid": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uuid",
                        "description": "null only on legacy documents created before packs existed."
                    },
                    "sent_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time",
                        "description": "When the group was sent (null while DRAFT)."
                    },
                    "member_count": {
                        "type": "integer"
                    },
                    "current_document_uuid": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "documents": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/SignWithSimplifiDocumentDetail"
                        }
                    }
                }
            }
        }
    }
}
