{
  "openapi": "3.1.0",
  "info": {
    "title": "AllSign Public API",
    "description": "API pública de AllSign — endpoints documentados en developers.allsign.io.\nImporta este archivo en Postman para empezar a integrar.",
    "version": "2.0.0",
    "contact": {
      "name": "AllSign Developer Support",
      "url": "https://developers.allsign.io"
    }
  },
  "servers": [
    {
      "url": "/v2",
      "description": "V2 API base path"
    }
  ],
  "paths": {
    "/test/security": {
      "get": {
        "tags": [
          "Security Test"
        ],
        "summary": "Test API Security",
        "description": "🔐 **Security Test Endpoint**\n    \n    Este endpoint simple retorna `true` si la autenticación es exitosa.\n    \n    **Propósito:**\n    - Validar que tu API key V2 funciona correctamente\n    - Verificar los scopes asignados\n    - Probar la autenticación Bearer token\n    \n    **Requisitos:**\n    - Header: `Authorization: Bearer allsign_live_sk_xxx`\n    - Scope mínimo: `document:read` (o cualquier scope de documento)\n    \n    **Casos de prueba:**\n    \n    ✅ **Éxito (200):**\n    ```bash\n    curl -X GET \"https://api.allsign.io/v2/test/security\" \\\n      -H \"Authorization: Bearer allsign_live_sk_8f3k2j9sd8f7s6d5f4g3h2j1k0m9n8b7\"\n    ```\n    \n    ❌ **Sin autenticación (401):**\n    ```bash\n    curl -X GET \"https://api.allsign.io/v2/test/security\"\n    ```\n    \n    ❌ **Key inválida (401):**\n    ```bash\n    curl -X GET \"https://api.allsign.io/v2/test/security\" \\\n      -H \"Authorization: Bearer invalid_key_12345\"\n    ```\n    \n    ❌ **Sin permisos (403):**\n    ```bash\n    # Si tu key solo tiene signature:read pero no document:*\n    curl -X GET \"https://api.allsign.io/v2/test/security\" \\\n      -H \"Authorization: Bearer allsign_live_sk_xxx\"\n    ```\n    \n    **Respuesta exitosa:**\n    ```json\n    {\n        \"success\": true,\n        \"message\": \"API V2 security validated successfully\",\n        \"authenticatedUser\": \"user@company.com\",\n        \"tenantId\": \"550e8400-e29b-41d4-a716-446655440000\",\n        \"scopes\": [\"document:read\", \"document:write\"],\n        \"environment\": \"live\"\n    }\n    ```",
        "operationId": "test_security_test_security_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Autenticación exitosa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecurityTestResponse"
                },
                "example": {
                  "success": true,
                  "message": "API V2 security validated successfully",
                  "authenticatedUser": "user@company.com",
                  "tenantId": "550e8400-e29b-41d4-a716-446655440000",
                  "scopes": [
                    "document:read",
                    "document:write",
                    "signature:*"
                  ],
                  "environment": "live"
                }
              }
            }
          },
          "401": {
            "description": "No autenticado - API key faltante o inválida",
            "content": {
              "application/json": {
                "example": {
                  "detail": "Invalid or expired API key"
                }
              }
            }
          },
          "403": {
            "description": "Sin permisos - Scopes insuficientes",
            "content": {
              "application/json": {
                "example": {
                  "detail": "Insufficient permissions. Requires ANY of these scopes: document:read, document:*. Your scopes: signature:read"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Create Document (With Credit Tracking)",
        "description": "# Create a new document with enterprise credit tracking\n    \n    ## Credit System Flow\n    \n    This endpoint demonstrates the complete credit lifecycle:\n    \n    ### 1. Pre-Authorization (Reserve)\n    ```\n    - Check if tenant has enough credits\n    - Reserve credits before processing (2-phase commit)\n    - If insufficient balance → 402 Payment Required\n    ```\n    \n    ### 2. Processing\n    ```\n    - Create document in database\n    - Process file (upload to S3, etc.)\n    - Track performance metrics\n    ```\n    \n    ### 3. Settlement\n    ```\n    Success path:\n    - Settle reservation (commit credits)\n    - Create immutable ledger entry\n    - Track API usage event\n    \n    Failure path:\n    - Release reservation (return credits)\n    - Log error\n    - Return appropriate error code\n    ```\n    \n    ## Credits Required\n    \n    - **document_signature**: 1 credit per document\n    - Configurable per tenant and plan\n    \n    ## Example\n    \n    ```bash\n    curl -X POST \"https://api.allsign.io/v2/documents\" \\\n      -H \"Authorization: Bearer allsign_live_sk_xxx\" \\\n      -H \"Content-Type: application/json\" \\\n      -d '{\n        \"name\": \"Contract.pdf\",\n        \"description\": \"Sample contract\"\n      }'\n    ```\n    \n    ## Response Codes\n    \n    - **201**: Document created successfully\n    - **401**: Unauthorized (invalid API key)\n    - **402**: Payment Required (insufficient credits)\n    - **403**: Forbidden (insufficient scopes)\n    - **500**: Internal error (credits released automatically)",
        "operationId": "create_document_v2_documents__post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "mode",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "sync",
                "async"
              ],
              "type": "string",
              "description": "'sync' waits for completion (201). 'async' returns immediately (202) — use progressUrl for real-time updates.",
              "default": "sync",
              "title": "Mode"
            },
            "description": "'sync' waits for completion (201). 'async' returns immediately (202) — use progressUrl for real-time updates."
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentCreateRequestV2"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Document created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SimpleDocumentResponse"
                },
                "example": {
                  "id": "550e8400-e29b-41d4-a716-446655440000",
                  "name": "Contract.pdf",
                  "description": "Sample contract",
                  "createdAt": "2024-11-23T20:00:00Z",
                  "creditsConsumed": 1
                }
              }
            }
          },
          "402": {
            "description": "Payment Required - Insufficient credits",
            "content": {
              "application/json": {
                "example": {
                  "detail": "Insufficient credits. Required: 1, Available: 0. Please add credits to continue."
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "List Documents (Cursor Pagination)",
        "description": "# Cursor-based document listing with filtering and scopes\n\n    This endpoint now uses **only cursor pagination** to keep responses fast and stable.\n    Request the first batch with `limit` and reuse the `nextCursor` value to continue.\n\n    ```bash\n    # First page\n    GET /v2/documents?limit=20&scope=accessible\n\n    # Next page\n    GET /v2/documents?limit=20&scope=accessible&cursor={nextCursor}\n    ```\n\n    ## Highlights\n    - ✅ Cursor pagination aligned with the sort order (created_at / updated_at)\n\n    ## Response Meta\n    ```json\n    \"meta\": {\n      \"limit\": 20,\n      \"hasNext\": true,\n      \"nextCursor\": \"eyJz...\",\n      \"prevCursor\": null\n    }\n    ```\n\n    ## Example filters\n    ```bash\n    GET /v2/documents?scope=org&name=invoice&createdAfter=2024-11-01&sortBy=created_at\n    ```",
        "operationId": "get_documents_v2_documents__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Cursor"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 10,
              "title": "Limit"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DocumentScopeEnum",
              "default": "owner"
            }
          },
          {
            "name": "folderId",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Folderid"
            }
          },
          {
            "name": "signatureStatus",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Signaturestatus"
            }
          },
          {
            "name": "createdAfter",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Createdafter"
            }
          },
          {
            "name": "createdBefore",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Createdbefore"
            }
          },
          {
            "name": "includeAllHistory",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Includeallhistory"
            }
          },
          {
            "name": "orgId",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Orgid"
            }
          },
          {
            "name": "sortBy",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DocumentSortFieldEnum",
              "default": "created_at"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/SortOrderEnum",
              "default": "desc"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Search"
            }
          },
          {
            "name": "createdBy",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Createdby"
            }
          },
          {
            "name": "forUserId",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Foruserid"
            }
          },
          {
            "name": "includeSigners",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true,
              "title": "Includesigners"
            }
          },
          {
            "name": "includeFolders",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Includefolders"
            }
          },
          {
            "name": "includeDocumentStats",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Includedocumentstats"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Documents retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentListV2Response"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing Bearer token"
          },
          "403": {
            "description": "Forbidden - Insufficient scopes"
          },
          "422": {
            "description": "Validation Error - Invalid query parameters"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/documents/stats": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Get Document Statistics",
        "description": "Get aggregate statistics about user's documents.\n    \n    Returns:\n    - Total document count\n    - Count by document type\n    - Recent documents (last 7 days)\n    \n    ## Date Filters\n    - `createdAfter` / `createdBefore` accept ISO 8601 timestamps and reuse the same filtering semantics as `GET /v2/documents`.\n    - If either parameter is provided, all counters (including `recentCount`) are computed only for the filtered range.\n    - If both parameters are omitted, the API defaults to the last 365 days to keep queries bounded, and `recentCount` still reflects the last 7 days inside that window.",
        "operationId": "get_documents_stats_v2_documents_stats_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DocumentScopeEnum",
              "default": "accessible"
            }
          },
          {
            "name": "createdAfter",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Createdafter"
            }
          },
          {
            "name": "createdBefore",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "format": "date-time"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Createdbefore"
            }
          },
          {
            "name": "includeAllHistory",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "title": "Includeallhistory"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentStatsV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Get Document by ID",
        "description": "Retrieve a single document by its ID.\n    \n    Returns 404 if:\n    - Document doesn't exist\n    - User doesn't own the document",
        "operationId": "get_document_by_id_endpoint_documents__document_id__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Documents"
        ],
        "summary": "Update Document (Partial)",
        "description": "# Partially update a document\n    \n    Update specific fields of a document without affecting other fields.\n    All fields are optional - only provided fields will be updated.\n    \n    ## Common Use Cases\n    \n    ### Move document to folder\n    ```json\n    {\"folderId\": \"550e8400-e29b-41d4-a716-446655440000\"}\n    ```\n    \n    ### Remove from folder\n    ```json\n    {\"folderId\": null}\n    ```\n    \n    ### Rename document\n    ```json\n    {\"name\": \"New Contract Name.pdf\"}\n    ```\n    \n    ### Update config\n    ```json\n    {\n      \"config\": {\n        \"sendInvitations\": true,\n        \"sendByEmail\": true,\n        \"startAtStep\": 3\n      }\n    }\n    ```\n    \n    ### Update permissions\n    ```json\n    {\n      \"permissions\": {\n        \"ownerEmail\": \"newowner@example.com\",\n        \"collaborators\": [\n          {\"email\": \"user@example.com\", \"permissions\": [\"read\", \"update\"]}\n        ]\n      }\n    }\n    ```\n    \n    ## Response Codes\n    \n    - **200**: Document updated successfully\n    - **400**: Invalid request (no fields provided, validation error)\n    - **401**: Unauthorized (invalid API key)\n    - **403**: Forbidden (insufficient scopes)\n    - **404**: Document not found or no access\n    - **422**: Validation error (invalid folder_id, etc.)\n    - **500**: Internal error",
        "operationId": "patch_document_v2_documents__document_id__patch",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentPatchRequestV2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document updated successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentV2Response"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - No fields provided or validation error"
          },
          "404": {
            "description": "Document not found or no access"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Documents"
        ],
        "summary": "Delete Document",
        "description": "Delete a single document. Requires `document:delete` scope. Documents that are fully signed (TODOS_FIRMARON) or have signatures in progress (ESPERANDO_FIRMAS) cannot be deleted. Associated S3 files (PDFs, evidence, NOM-151 constancias) are cleaned up in the background.",
        "operationId": "delete_document_documents__document_id__delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteDocumentResponseV2"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/extend": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Extend Document Signing Deadline",
        "description": "Extend or reactivate the signing deadline for a document.\n    \n    **Owner-only** — only the document owner can extend the deadline.\n    \n    If the document is in EXPIRADO status, it will be reactivated to\n    ESPERANDO_FIRMAS with the new deadline.\n    \n    The `extendedCount` tracks how many times the deadline has been extended.",
        "operationId": "extend_document_deadline_documents__document_id__extend_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ExtendDeadlineRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtendDeadlineResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/invite": {
      "post": {
        "tags": [
          "Invitations",
          "Invitations"
        ],
        "summary": "Invite a single participant (guest mode)",
        "description": "Creates a GuestSession and sends the guest signing link via email and/or WhatsApp. The participant must already exist as a signer on the document.",
        "operationId": "invite_participant_v2_documents__document_id__invite_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InviteRequestV2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InviteResponseV2"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/invite-bulk": {
      "post": {
        "tags": [
          "Invitations",
          "Invitations"
        ],
        "summary": "Invite multiple participants (guest mode)",
        "description": "Creates GuestSessions and sends guest signing links via email and/or WhatsApp for multiple participants in a single call.",
        "operationId": "invite_participants_bulk_v2_documents__document_id__invite_bulk_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkInviteRequestV2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InviteResponseV2"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/start-signing": {
      "post": {
        "tags": [
          "Invitations",
          "Signing Lifecycle"
        ],
        "summary": "Start the signing process",
        "description": "Advances the document from setup stages (RECOLECTANDO_FIRMANTES, SELLOS_PDF) to ESPERANDO_FIRMAS and charges credits based on the final stamp configuration.\n\nCredits are calculated from the document's current signature_validations in the DB, so the cost reflects whatever stamps were configured last.\n\nThis is idempotent — if credits were already settled for this document (e.g. during correction re-entry), no additional charge is made.\n\nIf you also need to send email/WhatsApp invitations, use `POST /{document_id}/invite-bulk` instead — it calls start-signing internally.",
        "operationId": "start_signing_documents__document_id__start_signing_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StartSigningResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment Required - Insufficient credits",
            "content": {
              "application/json": {
                "example": {
                  "detail": {
                    "code": "INSUFFICIENT_CREDITS",
                    "message": "Insufficient credits",
                    "required": 3,
                    "available": 1
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/correction-context": {
      "get": {
        "tags": [
          "Correction",
          "Correction"
        ],
        "summary": "Get document correction context",
        "description": "Returns what edit operations the admin can perform on this document. Uses DocuSign-style rules based on which signers have already signed.",
        "operationId": "get_document_correction_context_documents__document_id__correction_context_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CorrectionContextResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/void": {
      "post": {
        "tags": [
          "Correction",
          "Correction"
        ],
        "summary": "Void document",
        "description": "Voids a document, cancelling all pending signatures. Already-signed signatures are preserved in the audit trail.",
        "operationId": "void_document_documents__document_id__void_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VoidRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VoidResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/enter-correction": {
      "post": {
        "tags": [
          "Correction",
          "Correction"
        ],
        "summary": "Enter correction mode",
        "description": "Temporarily locks the document for editing. Signers will see 'Document is being updated' while in this state.",
        "operationId": "enter_correction_mode_documents__document_id__enter_correction_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/exit-correction": {
      "post": {
        "tags": [
          "Correction",
          "Correction"
        ],
        "summary": "Exit correction mode",
        "description": "Unlocks the document after owner editing is complete. Returns the document to ESPERANDO_FIRMAS so signers can resume.",
        "operationId": "exit_correction_mode_documents__document_id__exit_correction_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/add-signer": {
      "post": {
        "tags": [
          "Correction",
          "Correction"
        ],
        "summary": "Add signer to document",
        "description": "Add a signer to a document. Finds or creates the user under the tenant, grants document access, and creates the signature record.",
        "operationId": "add_signer_v2_documents__document_id__add_signer_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddSignerRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/signers/{signature_id}": {
      "delete": {
        "tags": [
          "Correction",
          "Correction"
        ],
        "summary": "Remove signer from active document",
        "description": "Remove a signer from a document that has already been sent. Validates that the signer hasn't already signed.",
        "operationId": "remove_signer_correction_documents__document_id__signers__signature_id__delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "signature_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Signature Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{document_id}/signature-fields": {
      "post": {
        "tags": [
          "Signature Fields",
          "Signature Fields"
        ],
        "summary": "Add a signature field to a document",
        "description": "Add a signature field to a document.\n\nSupports both Bearer token and X-Service-Key authentication.",
        "operationId": "add_signature_field_v2_documents__document_id__signature_fields_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddSignatureFieldRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignatureFieldResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Signature Fields",
          "Signature Fields"
        ],
        "summary": "Update a signature field in a document",
        "description": "Update position, page, or includeInAllPages for a signature field.\n\nSupports both Bearer token and X-Service-Key authentication.",
        "operationId": "update_signature_field_v2_documents__document_id__signature_fields_put",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateSignatureFieldRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignatureFieldResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Signature Fields",
          "Signature Fields"
        ],
        "summary": "Delete a signature field from a document",
        "description": "Delete a signature field from a document.\n\nSupports both Bearer token and X-Service-Key authentication.",
        "operationId": "delete_signature_field_v2_documents__document_id__signature_fields_delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "document_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Document Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DeleteSignatureFieldRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignatureFieldResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/workflows/{workflow_id}/status": {
      "get": {
        "tags": [
          "Document Progress",
          "Document Progress"
        ],
        "summary": "Get Document Creation Status (JSON)",
        "description": "Lightweight JSON endpoint for polling document creation progress.\n    \n    Use this if you prefer simple polling over SSE streaming.\n    Poll every 2-5 seconds until `status` is `completed` or `failed`.\n    \n    ## Authentication\n    - **API Key**: `Authorization: Bearer allsign_live_sk_xxx`\n    - **Internal**: `X-Service-Key` header\n    \n    ## Response Status Values\n    - `processing` — Document is being created\n    - `completed` — Document ready, `documentId` is set\n    - `failed` — Processing failed, `error` is set",
        "operationId": "get_workflow_status_documents_workflows__workflow_id__status_get",
        "parameters": [
          {
            "name": "workflow_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Workflow Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WorkflowStatusResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/workflows/{workflow_id}/progress": {
      "get": {
        "tags": [
          "Document Progress",
          "Document Progress"
        ],
        "summary": "Stream Document Creation Progress (SSE)",
        "description": "Server-Sent Events endpoint for real-time document creation progress.\n    \n    Connect to this endpoint after receiving a 202 Accepted response from\n    `POST /v2/documents?mode=async`.\n    \n    ## Authentication\n    - **API Key**: `Authorization: Bearer allsign_live_sk_xxx`\n    - **Internal**: `X-Service-Key` header\n    \n    ## Event Types\n    - **progress**: Processing step update with percentage\n    - **complete**: Processing finished, includes final documentId\n    - **error**: Processing failed\n    \n    ## Resumability\n    On connect, checks both Redis stored state and Temporal workflow status\n    to immediately send the current state — handles page refreshes and \n    reconnections gracefully.",
        "operationId": "stream_document_progress_documents_workflows__workflow_id__progress_get",
        "parameters": [
          {
            "name": "workflow_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Workflow Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          },
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Authorization"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SSE event stream",
            "content": {
              "application/json": {
                "schema": {}
              },
              "text/event-stream": {}
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/documents/bulk": {
      "delete": {
        "tags": [
          "Documents"
        ],
        "summary": "Bulk Delete Documents",
        "description": "Delete multiple documents at once. Requires `document:delete` scope. Returns per-document success/failure details. Maximum 100 documents per request. Documents that are fully signed or have signatures in progress will be skipped. Associated S3 files are cleaned up in the background.",
        "operationId": "bulk_delete_documents_documents_bulk_delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BulkDeleteRequestV2"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BulkDeleteResponseV2"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/folders": {
      "get": {
        "tags": [
          "Folders"
        ],
        "summary": "List Folders in Tree Structure",
        "description": "Get folders in hierarchical tree structure.\n\n    ## Tenant-aware behavior\n    Folder visibility is determined automatically by the user's tenant membership:\n    - **Tenant member (owner/admin)**: sees ALL folders belonging to their tenant.\n    - **Tenant member (member/developer/viewer)**: sees tenant folders that contain\n      documents they have access to (`has_access`).\n    - **No tenant membership**: sees personal folders (`owner_id = user`).\n\n    No extra parameters are needed — the server resolves the user's membership\n    and role from the API key / X-User-Id header.\n\n    Each folder in the response now includes a `tenantId` field (null for personal folders).\n\n    ## Authentication Modes\n    - **User API Key** (legacy): `Authorization: Bearer allsign_user_sk_xxx`\n    - **App API Key + X-User-Id** (multi-tenant apps):\n      ```\n      Authorization: Bearer allsign_live_sk_xxx\n      X-User-Id: 550e8400-e29b-41d4-a716-446655440000\n      ```\n\n    ## Response Structure\n    Returns a tree where each folder can have `subfolders` array.\n    Root-level folders have `parentId: null`.",
        "operationId": "get_folders_tree_endpoint_folders_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DocumentScopeEnum",
              "description": "Document scope: owner (default), org, tenant, or accessible",
              "default": "owner"
            },
            "description": "Document scope: owner (default), org, tenant, or accessible"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FolderListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Folders"
        ],
        "summary": "Create Folder",
        "description": "Create a new folder.\n\n    If the user is a tenant member, the folder is automatically assigned to\n    their tenant (`tenantId` in response). Viewers cannot create folders.\n\n    ## Parameters\n    - `name`: Folder name (1-255 characters)\n    - `parentId`: Parent folder ID (optional, null = root level)\n\n    ## Returns\n    Created folder details with `hasDocs: false`",
        "operationId": "create_folder_endpoint_folders_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FolderV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/folders/{folder_id}": {
      "get": {
        "tags": [
          "Folders"
        ],
        "summary": "Get Folder by ID",
        "description": "Get details of a single folder.\n\n    Returns 404 if:\n    - Folder doesn't exist\n    - User doesn't have access (not in same tenant, or not the owner for personal folders)",
        "operationId": "get_folder_endpoint_folders__folder_id__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "folder_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Folder Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FolderV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Folders"
        ],
        "summary": "Rename or Move Folder",
        "description": "Update folder name and/or parent.\n\n    ## Permissions\n    - **owner/admin**: can rename or move any folder in the tenant.\n    - **member/developer**: can only rename folders they created.\n    - **viewer**: cannot update folders (403).\n\n    ## Validation\n    - Cannot move folder into itself\n    - Cannot move folder into its descendants\n    - Parent must exist\n\n    Returns 400 if circular reference detected.",
        "operationId": "update_folder_endpoint_folders__folder_id__patch",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "folder_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Folder Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FolderUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FolderV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Folders"
        ],
        "summary": "Delete Folder",
        "description": "Delete a folder. Operation fails if the folder contains documents or subfolders.\n\n    ## Permissions\n    - **owner/admin**: can delete any folder in the tenant.\n    - **member/developer**: can only delete folders they created.\n    - **viewer**: cannot delete folders (403).",
        "operationId": "delete_folder_endpoint_folders__folder_id__delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "folder_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Folder Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Successful Response"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/folders/{folder_id}/documents": {
      "get": {
        "tags": [
          "Folders"
        ],
        "summary": "Get Documents in Folder",
        "description": "Get all documents in a specific folder.\n    \n    This is an alias/convenience endpoint for:\n    `GET /v2/documents?folderId={folder_id}`\n    \n    Supports pagination and all document filters.",
        "operationId": "get_folder_documents_endpoint_folders__folder_id__documents_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "folder_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Folder Id"
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 10000,
              "minimum": 1,
              "description": "Page number",
              "title": "Page"
            },
            "description": "Page number"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "description": "Items per page",
              "default": 10,
              "title": "Limit"
            },
            "description": "Items per page"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentListV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/users/me": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get current user profile",
        "description": "Returns basic metadata for the authenticated user (dual-mode auth supported). When impersonating via X-User-Id, the target user must belong to the same tenant as the API key owner.",
        "operationId": "get_current_user_profile_users_me_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserProfileV2Response"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/users/team": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "List Team Members",
        "description": "# List all members of your tenant (workspace)\n\n    Returns the team members that belong to the same tenant as the authenticated user.\n    Useful for obtaining user IDs to filter documents with `createdBy` on `GET /v2/documents`.\n\n    ## Permissions\n    - Requires **admin** or **owner** role within the tenant.\n\n    ## Example\n\n    ```bash\n    curl -X GET \"https://api.allsign.io/v2/users/team\" \\\n      -H \"Authorization: Bearer allsign_live_sk_xxx\"\n    ```\n\n    ## Use with documents filter\n\n    ```bash\n    # 1. List your team members\n    GET /v2/users/team\n\n    # 2. Use a member's ID to filter documents\n    GET /v2/documents?scope=accessible&createdBy={memberId}\n    ```",
        "operationId": "list_team_members_users_team_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Team members listed successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TeamListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing Bearer token"
          },
          "403": {
            "description": "Forbidden - Requires admin/owner role"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/files/upload/": {
      "post": {
        "tags": [
          "Files"
        ],
        "summary": "Upload file to S3",
        "description": "Upload a base64-encoded file to S3.\n\n    Used by the signing pipeline to store biometric photos, identity document\n    scans, and other verification artifacts.\n\n    The `key` must start with `signatures/` for security.\n    Maximum decoded file size: 10 MB.",
        "operationId": "upload_file_files_upload__post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FileUploadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileUploadResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/prior-verification": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Check prior identity verification for a signer",
        "description": "Checks if a signer (by email or phone) has a prior verified identity within the tenant. Returns captures if verified, so the signing pipeline can skip static verification steps (ID scan, name confirm). Phone lookup is used as fallback for WhatsApp-only signers.",
        "operationId": "get_prior_verification_onboarding_prior_verification_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Signer email to look up",
              "title": "Email"
            },
            "description": "Signer email to look up"
          },
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Signer phone fallback (WhatsApp-only signers)",
              "title": "Phone"
            },
            "description": "Signer phone fallback (WhatsApp-only signers)"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriorVerificationResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/sessions": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Create onboarding session",
        "description": "Creates a new onboarding session with a unique token. Returns the session info and a public URL for the user to access.",
        "operationId": "create_session_endpoint_onboarding_sessions_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateOnboardingSessionRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingSessionResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "List onboarding sessions",
        "description": "Paginated list of onboarding sessions for the authenticated tenant.",
        "operationId": "list_sessions_endpoint_onboarding_sessions_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1,
              "title": "Page"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 25,
              "title": "Pagesize"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by status",
              "title": "Status"
            },
            "description": "Filter by status"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/sessions/{session_id}/result": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Get session verification results",
        "description": "Returns the full verification results for a completed onboarding session, including extracted data, document type, and presigned capture URLs. Authenticated via API key with tenant isolation.",
        "operationId": "get_session_result_endpoint_onboarding_sessions__session_id__result_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Session Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingResultResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/validate": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Validate onboarding token",
        "description": "Validates an onboarding token and returns session configuration.",
        "operationId": "validate_token_endpoint_onboarding_validate_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateTokenResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/capture": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Upload document capture",
        "description": "Uploads a captured image or video for an onboarding session. The file is stored in S3 and queued for processing.",
        "operationId": "upload_capture_endpoint_onboarding_capture_post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_capture_endpoint_onboarding_capture_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CaptureUploadResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/status/{token}": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Get onboarding status",
        "description": "Poll the current status of an onboarding session.",
        "operationId": "get_status_endpoint_onboarding_status__token__get",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Token"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OnboardingStatusResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/onboarding/complete/{token}": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Complete onboarding",
        "description": "Marks an onboarding session as completed. Merges OCR results and applies any user corrections.",
        "operationId": "complete_session_endpoint_onboarding_complete__token__post",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Token"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CompleteOnboardingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompleteOnboardingResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "List contacts",
        "description": "Paginated list of contacts for the authenticated tenant. Supports search by name/email, filtering by tag, verification status, and source.",
        "operationId": "list_contacts_endpoint_contacts_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1,
              "title": "Page"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 25,
              "title": "Pagesize"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Search by name, email, or company",
              "title": "Search"
            },
            "description": "Search by name, email, or company"
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by tag",
              "title": "Tag"
            },
            "description": "Filter by tag"
          },
          {
            "name": "verified",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by identity verified",
              "title": "Verified"
            },
            "description": "Filter by identity verified"
          },
          {
            "name": "source",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by source: manual, api, invitation, onboarding",
              "title": "Source"
            },
            "description": "Filter by source: manual, api, invitation, onboarding"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Create a contact",
        "description": "Create a new contact. If a user with this email already exists, a profile is linked to them.",
        "operationId": "create_contact_endpoint_contacts_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDetailResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/autocomplete": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Autocomplete contacts",
        "description": "Lightweight typeahead: returns up to 5 contacts matching the query.",
        "operationId": "autocomplete_contacts_endpoint_contacts_autocomplete_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "minLength": 2,
              "description": "Search query (min 2 chars)",
              "default": "",
              "title": "Q"
            },
            "description": "Search query (min 2 chars)"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{contact_id}": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Get contact detail",
        "description": "Full contact profile including linked documents and verification status.",
        "operationId": "get_contact_endpoint_contacts__contact_id__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Contact Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDetailResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "put": {
        "tags": [
          "Contacts"
        ],
        "summary": "Update a contact",
        "description": "Update CRM fields (company, job title, notes, tags) on a contact profile.",
        "operationId": "update_contact_endpoint_contacts__contact_id__put",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Contact Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDetailResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "summary": "Delete a contact profile",
        "description": "Removes the CRM profile. The underlying user account is NOT deleted.",
        "operationId": "delete_contact_endpoint_contacts__contact_id__delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Contact Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/bulk": {
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Bulk create contacts",
        "description": "Create up to 100 contacts in a single request. Each item is processed independently — failures do NOT abort the batch. Response contains per-item success/failure details so clients can surface row-level errors in their import UI. Existing profiles (same email under the tenant) are returned as `success=true` with the existing `contactId`.",
        "operationId": "bulk_create_endpoint_contacts_bulk_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactBulkCreateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactBulkResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Contacts"
        ],
        "summary": "Bulk update contacts",
        "description": "Partial update of up to 100 contacts. Each item requires an `id`. Per-item semantics are identical to `PUT /v2/contacts/{id}` — only the keys present in the item are touched. Failures are captured per item.",
        "operationId": "bulk_update_endpoint_contacts_bulk_patch",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactBulkUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactBulkResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Contacts"
        ],
        "summary": "Bulk delete contacts",
        "description": "Delete up to 100 contact profiles. Per-item tenant isolation (a contact from another tenant reports `Contact not found`). The underlying User rows are NOT deleted — only the CRM profile, matching the behaviour of `DELETE /v2/contacts/{id}`.",
        "operationId": "bulk_delete_endpoint_contacts_bulk_delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactBulkDeleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactBulkResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{contact_id}/custom-fields": {
      "patch": {
        "tags": [
          "Contacts"
        ],
        "summary": "Patch contact custom fields",
        "description": "Atomic add/update/remove operation on ContactProfile.custom_fields. Prefer this over PUT /contacts/{id} with customFields when you only need to change a handful of keys — it is race-safe (a concurrent client touching different keys no longer clobbers yours) and supports bulk-delete in a single round-trip.\n\nExample — delete 3 fields + rename one:\n```json\n{\n  \"set\":    { \"RFC\": \"NEW123\" },\n  \"remove\": [\"OldRFC\", \"TempNote\", \"LegacyKey\"]\n}\n```",
        "operationId": "patch_custom_fields_endpoint_contacts__contact_id__custom_fields_patch",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Contact Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomFieldsPatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactDetailResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/contacts/{contact_id}/documents": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "List documents for a contact",
        "description": "All documents where this contact is a signer.",
        "operationId": "list_contact_documents_endpoint_contacts__contact_id__documents_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "contact_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Contact Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/templates/": {
      "post": {
        "tags": [
          "DOCX Templates"
        ],
        "summary": "Upload Template",
        "description": "# Upload a Word (.docx) or PDF template\n\n    Upload a `.docx` file containing Jinja2-style placeholders (`{{ variable_name }}`).\n    The system will:\n\n    1. **Validate** the file is a valid DOCX or PDF\n    2. **Auto-detect** all `{{ }}` variables in the document (DOCX only)\n    3. **Infer** variable types (text, date, currency, etc.) from names\n    4. **Store** the original file in S3 for later reuse\n    5. **Return** the list of detected variables with rich metadata\n\n    ## Accepted formats\n    - `.docx` files — full variable detection and AI editing support\n    - `.pdf` files — stored as-is for overlay-based workflows",
        "operationId": "upload_docx_template_templates__post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_upload_docx_template_templates__post"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocxTemplateUploadResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "DOCX Templates"
        ],
        "summary": "List Templates",
        "description": "List all active templates for the authenticated user or organization. Supports filtering by file type, tags, category, and text search.",
        "operationId": "list_docx_templates_templates__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "fileType",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by 'docx' or 'pdf'",
              "title": "Filetype"
            },
            "description": "Filter by 'docx' or 'pdf'"
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Comma-separated tags filter",
              "title": "Tags"
            },
            "description": "Comma-separated tags filter"
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Filter by category",
              "title": "Category"
            },
            "description": "Filter by category"
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Search by name or description",
              "title": "Q"
            },
            "description": "Search by name or description"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocxTemplateListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/templates/{template_id}": {
      "get": {
        "tags": [
          "DOCX Templates"
        ],
        "summary": "Get Template Detail",
        "description": "Get full template detail including variable configuration and test data sets.",
        "operationId": "get_template_detail_templates__template_id__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "template_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Template Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocxTemplateDetailResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "DOCX Templates"
        ],
        "summary": "Update Template",
        "description": "Update template metadata (name, description, tags, category, AI editable, variable config).",
        "operationId": "update_docx_template_templates__template_id__patch",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "template_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Template Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocxTemplateUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocxTemplateDetailResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "DOCX Templates"
        ],
        "summary": "Delete Template",
        "description": "Delete a template. By default this is a soft-delete (marks the template inactive while preserving the S3 file for audit). Pass `?hard=true` to permanently remove the row and its underlying S3 object. The deletion is refused with 409 Conflict if any active document or chain still references this template — archive or complete those first.",
        "operationId": "delete_docx_template_templates__template_id__delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "template_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Template Id"
            }
          },
          {
            "name": "hard",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "If true, permanently delete the row and S3 object",
              "default": false,
              "title": "Hard"
            },
            "description": "If true, permanently delete the row and S3 object"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocxTemplateDeleteResponse"
                }
              }
            }
          },
          "404": {
            "description": "Template not found"
          },
          "403": {
            "description": "Caller does not own the template"
          },
          "409": {
            "description": "Template is in use by documents or chains"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chains": {
      "post": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Create Chain Endpoint",
        "description": "Create a document chain in DRAFT status.",
        "operationId": "create_chain_endpoint_chains_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChainCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChainResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Document Chains"
        ],
        "summary": "List Chains Endpoint",
        "description": "List document chains for the authenticated user.",
        "operationId": "list_chains_endpoint_chains_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1,
              "title": "Page"
            }
          },
          {
            "name": "pageSize",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 100,
              "minimum": 1,
              "default": 20,
              "title": "Pagesize"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Status"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChainListResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chains/{chain_id}": {
      "get": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Get Chain Endpoint",
        "description": "Get chain detail with roles and documents.",
        "operationId": "get_chain_endpoint_chains__chain_id__get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChainResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Patch Chain Endpoint",
        "description": "Edit a chain still in DRAFT status.\n\n- signature_validations → delegated per-doc to `update_document_v2`\n  (same path as PATCH /v2/documents/{id}) so validation normalization,\n  feature flags and SignatureState sync behave identically.\n- signature_field_config → DocumentField rows are rewritten per doc\n  via the shared chain_field_placement helper (same helper used by\n  create_chain).",
        "operationId": "patch_chain_endpoint_chains__chain_id__patch",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChainPatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChainResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Delete Chain",
        "description": "Delete a document chain. By default this performs a soft-delete (sets status=VOIDED) so audit history is preserved. Pass `?hard=true` to permanently remove the chain row plus its roles, variables, and guest sessions. The underlying Document rows survive (their chain_id becomes NULL) so any signed evidence is kept. Soft-delete is refused for chains in COMPLETED status — use hard delete if you really need to remove a completed chain's metadata.",
        "operationId": "delete_chain_endpoint_chains__chain_id__delete",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "hard",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "description": "If true, permanently remove the chain and its dependents",
              "default": false,
              "title": "Hard"
            },
            "description": "If true, permanently remove the chain and its dependents"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChainDeleteResponse"
                }
              }
            }
          },
          "404": {
            "description": "Chain not found"
          },
          "409": {
            "description": "Chain is in a protected status"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chains/{chain_id}/invite": {
      "post": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Invite Chain Endpoint",
        "description": "Send invitations for a chain.\nTransitions DRAFT → INVITED, creates guest sessions, charges credits.",
        "operationId": "invite_chain_endpoint_chains__chain_id__invite_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChainInviteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chains/{chain_id}/variables": {
      "get": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Get Variables Endpoint",
        "description": "Get variables to fill for a chain, optionally filtered by role.",
        "operationId": "get_variables_endpoint_chains__chain_id__variables_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "roleId",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Roleid"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VariablesToFillResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chains/{chain_id}/fill-variables": {
      "post": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Fill Variables Endpoint",
        "description": "Fill variables for a specific role. Propagates across all docs in the chain.",
        "operationId": "fill_variables_endpoint_chains__chain_id__fill_variables_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FillVariablesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FillVariablesResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/chains/{chain_id}/regenerate-pdf": {
      "post": {
        "tags": [
          "Document Chains"
        ],
        "summary": "Regenerate one document's PDF in a chain",
        "description": "Owner-initiated retry of a single document whose PDF generation previously failed. Reads the chain's `config.pdfStatus[docId]` and:\n\n- Returns 200 immediately if the doc is already SUCCESS (idempotent no-op)\n- Refuses with 409 if the chain is in a terminal state (COMPLETED, VOIDED, EXPIRED)\n- Otherwise starts a Temporal `RegenerateChainPdfWorkflow` and waits for completion. The workflow re-renders the doc and merges the new result into `pdfStatus`. If this regen is the LAST failed entry, the workflow's persist step automatically promotes `chain.status` back to SIGNING.\n\nConcurrent calls for the same `(chain_id, document_id)` attach to the running workflow via `id_conflict_policy=USE_EXISTING` — they all see the same final result.",
        "operationId": "regenerate_chain_pdf_endpoint_chains__chain_id__regenerate_pdf_post",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "chain_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Chain Id"
            }
          },
          {
            "name": "docId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Document ID inside the chain whose PDF to re-render",
              "title": "Docid"
            },
            "description": "Document ID inside the chain whose PDF to re-render"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegenerateChainPdfResponse"
                }
              }
            }
          },
          "404": {
            "description": "Chain or document not found"
          },
          "409": {
            "description": "Chain is in a terminal state"
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/analytics/kpis": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Get KPI Metrics",
        "description": "Returns the main key performance indicators for your tenant:\n    - Total documents\n    - Completed / pending / expired counts\n    - Completion rate (%)\n    - Average signing time (hours)\n    \n    **Credits:** 1 credit per request.",
        "operationId": "analytics_kpis_analytics_kpis_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^(7d|30d|90d|12m)$",
              "description": "Time period",
              "default": "30d",
              "title": "Period"
            },
            "description": "Time period"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnalyticsKPIsResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/analytics/funnel": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Get Signing Funnel",
        "description": "Returns the signing funnel stages with document counts and percentages:\n    Enviados → En progreso → Completados → Expirados.\n    \n    **Credits:** 1 credit per request.",
        "operationId": "analytics_funnel_analytics_funnel_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^(7d|30d|90d|12m)$",
              "description": "Time period",
              "default": "30d",
              "title": "Period"
            },
            "description": "Time period"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/FunnelStepResponse"
                  },
                  "title": "Response Analytics Funnel Analytics Funnel Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/analytics/trend": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Get Monthly Trend",
        "description": "Returns signed document count and average signing time per month\n    for the last 6 months.\n    \n    **Credits:** 1 credit per request.",
        "operationId": "analytics_trend_analytics_trend_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MonthlyTrendResponse"
                  },
                  "title": "Response Analytics Trend Analytics Trend Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/analytics/events": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Get Recent Events",
        "description": "Returns the most recent user-facing document events across the tenant.\n    Internal events (S3, PDF processing, evidence generation) are excluded.\n    \n    **Credits:** 1 credit per request.",
        "operationId": "analytics_events_analytics_events_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 50,
              "minimum": 1,
              "description": "Max events to return",
              "default": 8,
              "title": "Limit"
            },
            "description": "Max events to return"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/RecentEventResponse"
                  },
                  "title": "Response Analytics Events Analytics Events Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/analytics/bottlenecks": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Get Signing Bottlenecks",
        "description": "Returns the signers with the most pending signatures and the\n    average number of days they have been pending.\n    \n    **Credits:** 1 credit per request.",
        "operationId": "analytics_bottlenecks_analytics_bottlenecks_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 20,
              "minimum": 1,
              "description": "Max bottleneck entries",
              "default": 5,
              "title": "Limit"
            },
            "description": "Max bottleneck entries"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/BottleneckResponse"
                  },
                  "title": "Response Analytics Bottlenecks Analytics Bottlenecks Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/analytics/team": {
      "get": {
        "tags": [
          "Analytics"
        ],
        "summary": "Get Team Activity",
        "description": "Returns per-member stats for the tenant:\n    - Documents sent\n    - Documents fully signed\n    - Completion rate (%)\n    \n    **Credits:** 1 credit per request.",
        "operationId": "analytics_team_analytics_team_get",
        "security": [
          {
            "Bearer Token": []
          }
        ],
        "parameters": [
          {
            "name": "period",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^(7d|30d|90d|12m)$",
              "description": "Time period",
              "default": "30d",
              "title": "Period"
            },
            "description": "Time period"
          },
          {
            "name": "X-On-Behalf-Of",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-On-Behalf-Of"
            }
          },
          {
            "name": "X-User-Id",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-User-Id"
            }
          },
          {
            "name": "X-Service-Key",
            "in": "header",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "X-Service-Key"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/TeamMemberActivityResponse"
                  },
                  "title": "Response Analytics Team Analytics Team Get"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AIEditChangeDetail": {
        "properties": {
          "section": {
            "type": "string",
            "title": "Section",
            "description": "Section/clause affected"
          },
          "before": {
            "type": "string",
            "title": "Before",
            "description": "Original text"
          },
          "after": {
            "type": "string",
            "title": "After",
            "description": "Modified text"
          },
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason",
            "description": "Reason for the change"
          }
        },
        "type": "object",
        "required": [
          "section",
          "before",
          "after"
        ],
        "title": "AIEditChangeDetail",
        "description": "A single change made by the AI."
      },
      "AIEditRequest": {
        "properties": {
          "prompt": {
            "type": "string",
            "maxLength": 2000,
            "minLength": 3,
            "title": "Prompt",
            "description": "Instruction for the AI (e.g., 'Hazlo más formal', 'Agrega cláusula de confidencialidad')"
          },
          "editType": {
            "type": "string",
            "title": "Edittype",
            "description": "Edit scope: 'full' (entire doc), 'selection' (specific text), 'clause' (add/modify clause), 'tone' (adjust formality)",
            "default": "full"
          },
          "selectionText": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Selectiontext",
            "description": "Selected text to edit (required when editType='selection')"
          },
          "model": {
            "type": "string",
            "title": "Model",
            "description": "LLM model to use (gpt-4o, gpt-4o-mini)",
            "default": "gpt-4o"
          }
        },
        "type": "object",
        "required": [
          "prompt"
        ],
        "title": "AIEditRequest",
        "description": "Request for AI-assisted template editing."
      },
      "AIEditResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "editId": {
            "type": "string",
            "title": "Editid",
            "description": "Edit history record UUID"
          },
          "summary": {
            "type": "string",
            "title": "Summary",
            "description": "AI summary of changes (in Spanish)"
          },
          "changes": {
            "items": {
              "$ref": "#/components/schemas/AIEditChangeDetail"
            },
            "type": "array",
            "title": "Changes",
            "description": "List of before/after changes"
          },
          "warnings": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Warnings",
            "description": "Legal warnings from the AI"
          },
          "versionBefore": {
            "type": "integer",
            "title": "Versionbefore",
            "description": "Version before edit"
          },
          "versionAfter": {
            "type": "integer",
            "title": "Versionafter",
            "description": "Version after edit"
          },
          "modelUsed": {
            "type": "string",
            "title": "Modelused"
          },
          "tokensUsed": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tokensused",
            "description": "Total tokens consumed"
          },
          "latencyMs": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Latencyms"
          }
        },
        "type": "object",
        "required": [
          "editId",
          "summary",
          "versionBefore",
          "versionAfter",
          "modelUsed"
        ],
        "title": "AIEditResponse",
        "description": "Response from AI editing, including diff and version info."
      },
      "AddSignatureFieldRequest": {
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id",
            "description": "ID of the signature field"
          },
          "signerEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signeremail",
            "description": "Email of the signer (optional if signerPhone provided)"
          },
          "signerPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signerphone",
            "description": "WhatsApp phone of the signer (must start with +). Optional if signerEmail provided."
          },
          "x": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "X",
            "description": "X coordinate of the signature field"
          },
          "y": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Y",
            "description": "Y coordinate of the signature field"
          },
          "pageNumber": {
            "type": "integer",
            "title": "Pagenumber",
            "description": "Page number where the signature field is located"
          },
          "width": {
            "type": "number",
            "title": "Width",
            "description": "Width of the signature field",
            "default": 200
          },
          "height": {
            "type": "number",
            "title": "Height",
            "description": "Height of the signature field",
            "default": 100
          },
          "anchorString": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Anchorstring",
            "description": "Text anchor to search for in the PDF to position the signature field"
          },
          "includeInAllPages": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Includeinallpages",
            "description": "Whether the signature field should be included in all pages",
            "default": false
          },
          "excludeFromPages": {
            "anyOf": [
              {
                "items": {
                  "type": "integer"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Excludefrompages",
            "description": "If includeInAllPages=True, exclude these page numbers"
          },
          "totalPages": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Totalpages",
            "description": "Total number of pages in the PDF (required when includeInAllPages=True)"
          },
          "type": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Type",
            "description": "Type of the field",
            "default": "signatureField"
          }
        },
        "type": "object",
        "required": [
          "pageNumber"
        ],
        "title": "AddSignatureFieldRequest",
        "description": "Request model for adding a single signature field to a document.\nAt least one of signerEmail or signerPhone must be provided."
      },
      "AddSignerRequest": {
        "properties": {
          "signerEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signeremail",
            "description": "The email of the signer to add (optional if signerPhone provided)."
          },
          "signerPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signerphone",
            "description": "The WhatsApp phone number of the signer (must start with +). Optional if signerEmail provided."
          },
          "invitedByEmail": {
            "type": "string",
            "title": "Invitedbyemail",
            "description": "The email of the user adding the signer."
          }
        },
        "type": "object",
        "required": [
          "invitedByEmail"
        ],
        "title": "AddSignerRequest"
      },
      "AnalyticsKPIsResponse": {
        "properties": {
          "totalDocs": {
            "type": "integer",
            "title": "Totaldocs",
            "description": "Total documents in period"
          },
          "completed": {
            "type": "integer",
            "title": "Completed",
            "description": "Documents fully signed"
          },
          "pending": {
            "type": "integer",
            "title": "Pending",
            "description": "Documents awaiting signatures"
          },
          "expired": {
            "type": "integer",
            "title": "Expired",
            "description": "Expired documents"
          },
          "completionRate": {
            "type": "number",
            "title": "Completionrate",
            "description": "Completion percentage (0-100)"
          },
          "avgSignTimeHours": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Avgsigntimehours",
            "description": "Average time to fully sign (hours)"
          }
        },
        "type": "object",
        "required": [
          "totalDocs",
          "completed",
          "pending",
          "expired",
          "completionRate"
        ],
        "title": "AnalyticsKPIsResponse",
        "description": "Key performance indicators for a tenant's signing activity."
      },
      "AutoLoginRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token"
          }
        },
        "type": "object",
        "required": [
          "token"
        ],
        "title": "AutoLoginRequest"
      },
      "AutoLoginResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "user_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "User Id"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "is_new_account": {
            "type": "boolean",
            "title": "Is New Account",
            "default": false
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "AutoLoginResponse"
      },
      "Body_upload_capture_endpoint_onboarding_capture_post": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "Onboarding session token"
          },
          "capture_type": {
            "type": "string",
            "title": "Capture Type",
            "description": "Type: id_front, id_back, selfie, liveness, video"
          },
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "Captured image or video file"
          },
          "device_info": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Device Info",
            "description": "JSON device info"
          }
        },
        "type": "object",
        "required": [
          "token",
          "capture_type",
          "file"
        ],
        "title": "Body_upload_capture_endpoint_onboarding_capture_post"
      },
      "Body_upload_docx_template_templates__post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "The .docx or .pdf template file"
          },
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Name",
            "description": "Display name for the template"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "description": "Optional description"
          },
          "tags": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tags",
            "description": "Comma-separated tags (e.g. 'legal,nda,ventas')"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category",
            "description": "Template category"
          },
          "aiEditable": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Aieditable",
            "description": "Enable AI editing",
            "default": true
          }
        },
        "type": "object",
        "required": [
          "file",
          "name"
        ],
        "title": "Body_upload_docx_template_templates__post"
      },
      "Body_verify_certificate_sat_verify_certificate_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "Archivo .cer del SAT"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_verify_certificate_sat_verify_certificate_post"
      },
      "Body_verify_ocsp_sat_verify_ocsp_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "Archivo .cer del SAT"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_verify_ocsp_sat_verify_ocsp_post"
      },
      "Body_verify_revocation_sat_verify_revocation_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "Archivo .cer del SAT"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_verify_revocation_sat_verify_revocation_post"
      },
      "BottleneckResponse": {
        "properties": {
          "signerName": {
            "type": "string",
            "title": "Signername"
          },
          "signerEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signeremail"
          },
          "pendingCount": {
            "type": "integer",
            "title": "Pendingcount"
          },
          "avgDays": {
            "type": "number",
            "title": "Avgdays",
            "description": "Avg days pending"
          }
        },
        "type": "object",
        "required": [
          "signerName",
          "pendingCount",
          "avgDays"
        ],
        "title": "BottleneckResponse",
        "description": "A signer with the most pending signatures."
      },
      "BulkDeleteRequestV2": {
        "properties": {
          "documentIds": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Documentids",
            "description": "List of document UUIDs to delete (max 100)."
          }
        },
        "type": "object",
        "required": [
          "documentIds"
        ],
        "title": "BulkDeleteRequestV2",
        "description": "Request body for bulk document deletion."
      },
      "BulkDeleteResponseV2": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "True if at least one document was deleted"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "deletedCount": {
            "type": "integer",
            "title": "Deletedcount"
          },
          "failedCount": {
            "type": "integer",
            "title": "Failedcount"
          },
          "details": {
            "items": {
              "$ref": "#/components/schemas/DeleteResultDetail"
            },
            "type": "array",
            "title": "Details",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "success",
          "message",
          "deletedCount",
          "failedCount"
        ],
        "title": "BulkDeleteResponseV2",
        "description": "Response for bulk document deletion."
      },
      "BulkInviteRequestV2": {
        "properties": {
          "participants": {
            "items": {
              "$ref": "#/components/schemas/DocumentParticipantData2"
            },
            "type": "array",
            "minItems": 1,
            "title": "Participants",
            "description": "Participants to invite."
          },
          "config": {
            "$ref": "#/components/schemas/ParticipantConfig",
            "description": "Shared delivery config for all participants."
          }
        },
        "type": "object",
        "required": [
          "participants",
          "config"
        ],
        "title": "BulkInviteRequestV2",
        "description": "Body for the bulk-invite endpoint."
      },
      "CacheStatusResponse": {
        "properties": {
          "totalCachedCrls": {
            "type": "integer",
            "title": "Totalcachedcrls",
            "default": 0
          },
          "totalRevokedInMemory": {
            "type": "integer",
            "title": "Totalrevokedinmemory",
            "default": 0
          },
          "estimatedRamMb": {
            "type": "number",
            "title": "Estimatedrammb",
            "default": 0.0
          },
          "caches": {
            "additionalProperties": {
              "$ref": "#/components/schemas/CrlCacheEntry"
            },
            "type": "object",
            "title": "Caches",
            "default": {}
          }
        },
        "type": "object",
        "title": "CacheStatusResponse",
        "description": "Response for GET /revocation-cache-status."
      },
      "CaptureResult": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "captureType": {
            "type": "string",
            "title": "Capturetype"
          },
          "ocrStatus": {
            "type": "string",
            "title": "Ocrstatus"
          },
          "ocrResult": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ocrresult"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "verificationStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationstatus",
            "description": "passed, failed, skipped, error, processing"
          },
          "verificationPassed": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationpassed",
            "description": "Whether all verification agents passed for this capture"
          },
          "verificationErrors": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationerrors",
            "description": "Human-readable error messages (e.g. 'Not a valid ID')"
          },
          "verificationWarnings": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationwarnings",
            "description": "Non-blocking warnings from agents"
          },
          "verificationConfidence": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationconfidence",
            "description": "Overall confidence 0.0–1.0"
          },
          "pipelineAgents": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pipelineagents",
            "description": "Agent IDs that ran for this capture"
          }
        },
        "type": "object",
        "required": [
          "id",
          "captureType",
          "ocrStatus",
          "createdAt"
        ],
        "title": "CaptureResult",
        "description": "Individual capture result."
      },
      "CaptureUploadResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "captureId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Captureid"
          },
          "captureType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Capturetype"
          },
          "ocrStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ocrstatus"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "verificationStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationstatus",
            "description": "passed, failed, skipped, error"
          },
          "verificationPassed": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationpassed",
            "description": "Whether all verification agents passed"
          },
          "verificationErrors": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationerrors",
            "description": "Human-readable error messages from failed agents"
          },
          "verificationWarnings": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationwarnings",
            "description": "Non-blocking warnings from agents"
          },
          "verificationConfidence": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationconfidence",
            "description": "Overall confidence 0.0–1.0"
          },
          "pipelineAgents": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pipelineagents",
            "description": "List of agent IDs that ran (for contextual UX messages)"
          },
          "documentType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Documenttype",
            "description": "Detected document type: INE_FRONT, PASSPORT, DRIVERS_LICENSE_MX, etc."
          },
          "skipBack": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Skipback",
            "description": "If true, frontend should skip id_back capture (e.g., for passports)"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "CaptureUploadResponse",
        "description": "Response after uploading a capture."
      },
      "CertBasicInfo": {
        "properties": {
          "serialNumber": {
            "type": "string",
            "title": "Serialnumber"
          },
          "subjectCn": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Subjectcn"
          },
          "issuerCn": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Issuercn"
          },
          "notBefore": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notbefore"
          },
          "notAfter": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notafter"
          }
        },
        "type": "object",
        "required": [
          "serialNumber"
        ],
        "title": "CertBasicInfo",
        "description": "Basic certificate info extracted from the .cer for revocation checks."
      },
      "CertificateInfoResponse": {
        "properties": {
          "rfc": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Rfc",
            "description": "RFC del titular"
          },
          "curp": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Curp",
            "description": "CURP del titular"
          },
          "legalName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Legalname",
            "description": "Nombre o razón social"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email",
            "description": "Email del certificado"
          },
          "serialNumber": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Serialnumber",
            "description": "Número de serie del certificado"
          },
          "certificateNumber": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Certificatenumber",
            "description": "Número de certificado formateado SAT"
          },
          "certificateType": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CertificateType"
              },
              {
                "type": "null"
              }
            ],
            "description": "Tipo: FIEL o CSD"
          },
          "issuer": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Issuer",
            "description": "Emisor del certificado (CA)"
          },
          "validFrom": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Validfrom",
            "description": "Vigencia desde"
          },
          "validUntil": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Validuntil",
            "description": "Vigencia hasta"
          },
          "isExpired": {
            "type": "boolean",
            "title": "Isexpired",
            "description": "¿Está expirado?",
            "default": false
          },
          "fingerprint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fingerprint",
            "description": "SHA-1 fingerprint del certificado"
          }
        },
        "type": "object",
        "title": "CertificateInfoResponse",
        "description": "Extracted metadata from a SAT .cer certificate."
      },
      "CertificateType": {
        "type": "string",
        "enum": [
          "FIEL",
          "CSD",
          "UNKNOWN"
        ],
        "title": "CertificateType",
        "description": "SAT certificate types."
      },
      "ChainCreateRequest": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "templateIds": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "minItems": 1,
            "title": "Templateids"
          },
          "templatePackId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Templatepackid"
          },
          "roles": {
            "items": {
              "$ref": "#/components/schemas/RoleCreate"
            },
            "type": "array",
            "minItems": 1,
            "title": "Roles"
          },
          "variableAssignments": {
            "items": {
              "$ref": "#/components/schemas/VariableAssignment"
            },
            "type": "array",
            "title": "Variableassignments"
          },
          "ownerValues": {
            "items": {
              "$ref": "#/components/schemas/OwnerFixedValue"
            },
            "type": "array",
            "title": "Ownervalues"
          },
          "signatureValidations": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signaturevalidations",
            "description": "Global signing config: {autografa: true, id_scan: true, ...}"
          },
          "signatureFieldConfig": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SignatureFieldConfig"
              },
              {
                "type": "null"
              }
            ],
            "description": "How to place signature fields when PDFs are generated"
          },
          "config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Config"
          },
          "expiresInDays": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expiresindays"
          }
        },
        "type": "object",
        "required": [
          "templateIds",
          "roles"
        ],
        "title": "ChainCreateRequest",
        "description": "POST /v2/chains — create a chain in DRAFT status."
      },
      "ChainDeleteCascade": {
        "properties": {
          "documents": {
            "type": "integer",
            "title": "Documents",
            "description": "Documents in the chain",
            "default": 0
          },
          "roles": {
            "type": "integer",
            "title": "Roles",
            "description": "Role records removed",
            "default": 0
          },
          "variables": {
            "type": "integer",
            "title": "Variables",
            "description": "Variable records removed",
            "default": 0
          },
          "guestSessions": {
            "type": "integer",
            "title": "Guestsessions",
            "description": "Guest sessions invalidated",
            "default": 0
          },
          "voidedDocuments": {
            "type": "integer",
            "title": "Voideddocuments",
            "description": "Docs auto-voided by a soft-delete (was in ESPERANDO_FIRMAS/etc.)",
            "default": 0
          },
          "cancelledSignatures": {
            "type": "integer",
            "title": "Cancelledsignatures",
            "description": "Pending signatures cancelled by the auto-void step",
            "default": 0
          }
        },
        "type": "object",
        "title": "ChainDeleteCascade",
        "description": "Detail of records removed alongside a chain."
      },
      "ChainDeleteResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Chain UUID that was deleted"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "Chain name"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "softDelete": {
            "type": "boolean",
            "title": "Softdelete",
            "description": "True if marked VOIDED, False if permanently removed",
            "default": true
          },
          "cascade": {
            "$ref": "#/components/schemas/ChainDeleteCascade"
          }
        },
        "type": "object",
        "required": [
          "id",
          "message"
        ],
        "title": "ChainDeleteResponse",
        "description": "Response after deleting a document chain."
      },
      "ChainDocumentResponse": {
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "chainPosition": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Chainposition"
          },
          "templateId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Templateid"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "ChainDocumentResponse",
        "description": "Minimal document info within a chain response."
      },
      "ChainInviteRequest": {
        "properties": {
          "invitationChannel": {
            "type": "string",
            "title": "Invitationchannel",
            "description": "email or whatsapp",
            "default": "email"
          }
        },
        "type": "object",
        "title": "ChainInviteRequest",
        "description": "POST /v2/chains/{id}/invite — send invitations, charge credits, transition to INVITED."
      },
      "ChainListResponse": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/ChainResponse"
            },
            "type": "array",
            "title": "Data"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "page": {
            "type": "integer",
            "title": "Page"
          },
          "pageSize": {
            "type": "integer",
            "title": "Pagesize"
          }
        },
        "type": "object",
        "required": [
          "data",
          "total",
          "page",
          "pageSize"
        ],
        "title": "ChainListResponse"
      },
      "ChainPatchRequest": {
        "properties": {
          "signatureValidations": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signaturevalidations",
            "description": "Global signing config: {autografa: true, ...}"
          },
          "signatureFieldConfig": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SignatureFieldConfig"
              },
              {
                "type": "null"
              }
            ],
            "description": "Replace DocumentField placements on all docs in the chain"
          }
        },
        "type": "object",
        "title": "ChainPatchRequest",
        "description": "PATCH /v2/chains/{id} — edit a DRAFT chain.\n\nScope (phase 1): signature type (autografa ↔ simple) + field placements.\nPer-doc metadata is routed through `update_document_v2` so the chain\nPATCH stays 100% compatible with the v2 single-doc PATCH."
      },
      "ChainResponse": {
        "properties": {
          "id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "status": {
            "$ref": "#/components/schemas/ChainStatusEnum"
          },
          "ownerId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Ownerid"
          },
          "tenantId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tenantid"
          },
          "templatePackId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Templatepackid"
          },
          "signatureValidations": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signaturevalidations"
          },
          "config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Config"
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expiresat"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          },
          "roles": {
            "items": {
              "$ref": "#/components/schemas/RoleResponse"
            },
            "type": "array",
            "title": "Roles",
            "default": []
          },
          "totalDocuments": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Totaldocuments"
          },
          "signedCount": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signedcount"
          },
          "documents": {
            "items": {
              "$ref": "#/components/schemas/ChainDocumentResponse"
            },
            "type": "array",
            "title": "Documents",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "ownerId",
          "createdAt",
          "updatedAt"
        ],
        "title": "ChainResponse"
      },
      "ChainStatusEnum": {
        "type": "string",
        "enum": [
          "DRAFT",
          "INVITED",
          "FILLING",
          "SIGNING",
          "COMPLETED",
          "VOIDED",
          "EXPIRED"
        ],
        "title": "ChainStatusEnum"
      },
      "Collaborator": {
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email",
            "description": "Email del colaborador"
          },
          "permissions": {
            "items": {
              "$ref": "#/components/schemas/PermissionType"
            },
            "type": "array",
            "title": "Permissions",
            "description": "Lista de permisos otorgados. Options: read, update, delete, sign, admin"
          }
        },
        "type": "object",
        "required": [
          "email"
        ],
        "title": "Collaborator",
        "description": "Colaborador con permisos específicos en el documento."
      },
      "CompleteOnboardingRequest": {
        "properties": {
          "confirmed": {
            "type": "boolean",
            "title": "Confirmed",
            "description": "User confirmed the extracted data is correct"
          },
          "corrections": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Corrections",
            "description": "Manual corrections to OCR-extracted fields"
          }
        },
        "type": "object",
        "required": [
          "confirmed"
        ],
        "title": "CompleteOnboardingRequest",
        "description": "Request to mark an onboarding session as completed."
      },
      "CompleteOnboardingResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "sessionId": {
            "type": "string",
            "title": "Sessionid"
          },
          "resultData": {
            "additionalProperties": true,
            "type": "object",
            "title": "Resultdata"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "success",
          "sessionId"
        ],
        "title": "CompleteOnboardingResponse",
        "description": "Response after completing an onboarding session."
      },
      "ContactBulkCreateRequest": {
        "properties": {
          "contacts": {
            "items": {
              "$ref": "#/components/schemas/ContactCreateRequest"
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Contacts",
            "description": "Contacts to create (max 100)."
          }
        },
        "type": "object",
        "required": [
          "contacts"
        ],
        "title": "ContactBulkCreateRequest",
        "description": "POST /v2/contacts/bulk — create up to 100 contacts in one request."
      },
      "ContactBulkDeleteRequest": {
        "properties": {
          "contactIds": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Contactids",
            "description": "ContactProfile ids to delete (max 100)."
          }
        },
        "type": "object",
        "required": [
          "contactIds"
        ],
        "title": "ContactBulkDeleteRequest",
        "description": "DELETE /v2/contacts/bulk — remove up to 100 contact profiles."
      },
      "ContactBulkResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "True if ≥1 item succeeded"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "succeededCount": {
            "type": "integer",
            "title": "Succeededcount"
          },
          "failedCount": {
            "type": "integer",
            "title": "Failedcount"
          },
          "details": {
            "items": {
              "$ref": "#/components/schemas/ContactBulkResultItem"
            },
            "type": "array",
            "title": "Details"
          }
        },
        "type": "object",
        "required": [
          "success",
          "message",
          "succeededCount",
          "failedCount"
        ],
        "title": "ContactBulkResponse",
        "description": "Bulk operation response. Mirrors BulkDeleteResponseV2 from documents."
      },
      "ContactBulkResultItem": {
        "properties": {
          "contactId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactid"
          },
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "ContactBulkResultItem",
        "description": "Per-item outcome in a bulk response."
      },
      "ContactBulkUpdateItem": {
        "properties": {
          "fullName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fullname"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "jobTitle": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Jobtitle"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          },
          "tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tags"
          },
          "customFields": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Customfields",
            "description": "Custom key-value pairs for template autofill"
          },
          "id": {
            "type": "string",
            "title": "Id",
            "description": "ContactProfile id to update"
          }
        },
        "type": "object",
        "required": [
          "id"
        ],
        "title": "ContactBulkUpdateItem",
        "description": "ContactUpdateRequest plus the target contact id."
      },
      "ContactBulkUpdateRequest": {
        "properties": {
          "contacts": {
            "items": {
              "$ref": "#/components/schemas/ContactBulkUpdateItem"
            },
            "type": "array",
            "maxItems": 100,
            "minItems": 1,
            "title": "Contacts",
            "description": "Contacts to update (max 100). Each item requires `id`."
          }
        },
        "type": "object",
        "required": [
          "contacts"
        ],
        "title": "ContactBulkUpdateRequest",
        "description": "PATCH /v2/contacts/bulk — partial update of up to 100 contacts."
      },
      "ContactCreateRequest": {
        "properties": {
          "email": {
            "type": "string",
            "title": "Email",
            "description": "Contact email — must be unique per tenant"
          },
          "fullName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fullname",
            "description": "Full name"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "jobTitle": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Jobtitle"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags"
          },
          "customFields": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Customfields",
            "description": "Custom key-value pairs for template autofill"
          }
        },
        "type": "object",
        "required": [
          "email"
        ],
        "title": "ContactCreateRequest",
        "description": "Create a contact manually."
      },
      "ContactDetailResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "userId": {
            "type": "string",
            "title": "Userid"
          },
          "fullName": {
            "type": "string",
            "title": "Fullname",
            "default": ""
          },
          "email": {
            "type": "string",
            "title": "Email",
            "default": ""
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "image": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Image"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "jobTitle": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Jobtitle"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags"
          },
          "customFields": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Customfields"
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "manual"
          },
          "identityVerified": {
            "type": "boolean",
            "title": "Identityverified",
            "default": false
          },
          "identityVerifiedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Identityverifiedat"
          },
          "nameVerified": {
            "type": "boolean",
            "title": "Nameverified",
            "default": false
          },
          "totalDocumentsSigned": {
            "type": "integer",
            "title": "Totaldocumentssigned",
            "default": 0
          },
          "totalDocumentsPending": {
            "type": "integer",
            "title": "Totaldocumentspending",
            "default": 0
          },
          "lastInteractionAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lastinteractionat"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          },
          "documents": {
            "items": {
              "$ref": "#/components/schemas/ContactDocumentItem"
            },
            "type": "array",
            "title": "Documents"
          }
        },
        "type": "object",
        "required": [
          "id",
          "userId",
          "createdAt",
          "updatedAt"
        ],
        "title": "ContactDetailResponse",
        "description": "Full contact profile with all metadata."
      },
      "ContactDocumentItem": {
        "properties": {
          "documentId": {
            "type": "string",
            "title": "Documentid"
          },
          "documentName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Documentname"
          },
          "signatureStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signaturestatus"
          },
          "signedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signedat"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "documentId",
          "createdAt"
        ],
        "title": "ContactDocumentItem",
        "description": "A document linked to this contact (as signer)."
      },
      "ContactListItem": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "ContactProfile ID"
          },
          "userId": {
            "type": "string",
            "title": "Userid"
          },
          "fullName": {
            "type": "string",
            "title": "Fullname",
            "default": ""
          },
          "email": {
            "type": "string",
            "title": "Email",
            "default": ""
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "authPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Authphone"
          },
          "primaryChannel": {
            "type": "string",
            "title": "Primarychannel",
            "default": "email"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "jobTitle": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Jobtitle"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags"
          },
          "customFields": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Customfields"
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "manual"
          },
          "identityVerified": {
            "type": "boolean",
            "title": "Identityverified",
            "default": false
          },
          "totalDocumentsSigned": {
            "type": "integer",
            "title": "Totaldocumentssigned",
            "default": 0
          },
          "totalDocumentsPending": {
            "type": "integer",
            "title": "Totaldocumentspending",
            "default": 0
          },
          "lastInteractionAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lastinteractionat"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "userId",
          "createdAt"
        ],
        "title": "ContactListItem",
        "description": "Compact row for the contacts table."
      },
      "ContactListResponse": {
        "properties": {
          "items": {
            "items": {
              "$ref": "#/components/schemas/ContactListItem"
            },
            "type": "array",
            "title": "Items"
          },
          "total": {
            "type": "integer",
            "title": "Total"
          },
          "page": {
            "type": "integer",
            "title": "Page"
          },
          "pageSize": {
            "type": "integer",
            "title": "Pagesize"
          },
          "totalPages": {
            "type": "integer",
            "title": "Totalpages"
          }
        },
        "type": "object",
        "required": [
          "items",
          "total",
          "page",
          "pageSize",
          "totalPages"
        ],
        "title": "ContactListResponse",
        "description": "Paginated list of contacts."
      },
      "ContactUpdateRequest": {
        "properties": {
          "fullName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Fullname"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone"
          },
          "company": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Company"
          },
          "jobTitle": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Jobtitle"
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Notes"
          },
          "tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tags"
          },
          "customFields": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Customfields",
            "description": "Custom key-value pairs for template autofill"
          }
        },
        "type": "object",
        "title": "ContactUpdateRequest",
        "description": "Partial update of a contact profile."
      },
      "CorrectionContextResponse": {
        "properties": {
          "signingStatus": {
            "type": "string",
            "title": "Signingstatus"
          },
          "canAddSigner": {
            "type": "boolean",
            "title": "Canaddsigner"
          },
          "isLocked": {
            "type": "boolean",
            "title": "Islocked"
          },
          "signers": {
            "items": {},
            "type": "array",
            "title": "Signers"
          }
        },
        "type": "object",
        "required": [
          "signingStatus",
          "canAddSigner",
          "isLocked"
        ],
        "title": "CorrectionContextResponse"
      },
      "CreateAuthTokenRequest": {
        "properties": {
          "document_id": {
            "type": "string",
            "title": "Document Id",
            "description": "Document ID to subscribe to"
          }
        },
        "type": "object",
        "required": [
          "document_id"
        ],
        "title": "CreateAuthTokenRequest"
      },
      "CreateChainAuthTokenRequest": {
        "properties": {
          "chain_id": {
            "type": "string",
            "title": "Chain Id",
            "description": "Chain ID to subscribe to"
          }
        },
        "type": "object",
        "required": [
          "chain_id"
        ],
        "title": "CreateChainAuthTokenRequest"
      },
      "CreateDocumentFromTemplateRequest": {
        "properties": {
          "templateId": {
            "type": "string",
            "title": "Templateid",
            "description": "UUID of the pre-saved DOCX template"
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Values",
            "description": "Key-value pairs mapping template variable names to their values",
            "example": {
              "fecha_inicio": "1 de abril de 2026",
              "monto_renta": "$15,000.00 MXN",
              "nombre_arrendador": "Pedro Páramo",
              "nombre_arrendatario": "Juan Preciado"
            }
          },
          "participants": {
            "items": {
              "$ref": "#/components/schemas/DocumentParticipant"
            },
            "type": "array",
            "title": "Participants",
            "description": "List of participants (signers)"
          },
          "fields": {
            "items": {
              "$ref": "#/components/schemas/SignatureFieldCreate"
            },
            "type": "array",
            "title": "Fields",
            "description": "List of signature fields"
          },
          "signatureValidation": {
            "$ref": "#/components/schemas/DocumentValidationSettings",
            "description": "Signature validation settings"
          },
          "config": {
            "$ref": "#/components/schemas/DocumentConfig",
            "description": "Document configuration"
          },
          "permissions": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentPermissions"
              },
              {
                "type": "null"
              }
            ],
            "description": "Document permissions and ownership"
          },
          "folderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Folderid",
            "description": "Optional folder ID to organize the document"
          },
          "folderName": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Foldername",
            "description": "Folder name – finds existing or creates one"
          }
        },
        "type": "object",
        "required": [
          "templateId",
          "values"
        ],
        "title": "CreateDocumentFromTemplateRequest",
        "description": "Request to create a document by filling a pre-saved DOCX template."
      },
      "CreateGuestTokenRequest": {
        "properties": {
          "guest_token": {
            "type": "string",
            "title": "Guest Token",
            "description": "Guest signing token from the invitation URL"
          }
        },
        "type": "object",
        "required": [
          "guest_token"
        ],
        "title": "CreateGuestTokenRequest"
      },
      "CreateOnboardingSessionRequest": {
        "properties": {
          "targetEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetemail"
          },
          "targetName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetname"
          },
          "targetPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetphone"
          },
          "config": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OnboardingConfig"
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresInHours": {
            "type": "integer",
            "title": "Expiresinhours",
            "description": "Hours until the session expires",
            "default": 24
          },
          "signatureId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signatureid",
            "description": "Optional link to signature flow"
          },
          "sendInvitation": {
            "type": "boolean",
            "title": "Sendinvitation",
            "description": "Send invitation email upon session creation",
            "default": false
          }
        },
        "type": "object",
        "title": "CreateOnboardingSessionRequest",
        "description": "Request to create a new onboarding session."
      },
      "CrlCacheEntry": {
        "properties": {
          "issuer": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Issuer"
          },
          "certCount": {
            "type": "integer",
            "title": "Certcount",
            "default": 0
          },
          "fetchedAt": {
            "type": "string",
            "title": "Fetchedat"
          },
          "isExpired": {
            "type": "boolean",
            "title": "Isexpired"
          },
          "ageMinutes": {
            "type": "integer",
            "title": "Ageminutes"
          },
          "ramMb": {
            "type": "number",
            "title": "Rammb",
            "default": 0.0
          }
        },
        "type": "object",
        "required": [
          "fetchedAt",
          "isExpired",
          "ageMinutes"
        ],
        "title": "CrlCacheEntry",
        "description": "Status of a single cached CRL."
      },
      "CustomFieldsPatchRequest": {
        "properties": {
          "set": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Set",
            "description": "Key/value pairs to upsert (merged with existing)."
          },
          "remove": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Remove",
            "description": "Keys to remove. Applied after `set`."
          }
        },
        "type": "object",
        "title": "CustomFieldsPatchRequest",
        "description": "Atomic patch operation for ContactProfile.custom_fields.\n\nSemantics:\n  - `set`   → upsert these key/value pairs (merges with existing).\n  - `remove`→ delete these keys if present (no-op if missing).\n  - Both can be specified in the same request; `remove` is applied\n    AFTER `set` so callers can \"rename\" a field in one call.\n\nThis is race-safe: a concurrent client deleting a DIFFERENT key will\nno longer clobber your delete (which is what happens with the PUT\nendpoint that overwrites the full dict)."
      },
      "DeleteDocumentResponseV2": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "documentId": {
            "type": "string",
            "title": "Documentid"
          },
          "s3KeysCleaned": {
            "type": "integer",
            "title": "S3Keyscleaned"
          }
        },
        "type": "object",
        "required": [
          "success",
          "message",
          "documentId",
          "s3KeysCleaned"
        ],
        "title": "DeleteDocumentResponseV2",
        "description": "Response for single document deletion."
      },
      "DeleteResultDetail": {
        "properties": {
          "documentId": {
            "type": "string",
            "title": "Documentid"
          },
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "documentId",
          "success"
        ],
        "title": "DeleteResultDetail",
        "description": "Per-document result in a bulk delete response."
      },
      "DeleteSignatureFieldRequest": {
        "properties": {
          "fieldId": {
            "type": "string",
            "title": "Fieldid",
            "description": "ID of the signature field to delete"
          },
          "signerEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signeremail",
            "description": "Email of the signer who owns the field (optional if signerPhone provided)"
          },
          "signerPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signerphone",
            "description": "WhatsApp phone of the signer (must start with +). Optional if signerEmail provided."
          },
          "deleteLinkedFields": {
            "type": "boolean",
            "title": "Deletelinkedfields",
            "description": "Whether to delete linked fields when deleting a signature field",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "fieldId"
        ],
        "title": "DeleteSignatureFieldRequest",
        "description": "Request model for deleting a signature field from a document.\nAt least one of signerEmail or signerPhone must be provided."
      },
      "DocumentConfig": {
        "properties": {
          "sendInvitations": {
            "type": "boolean",
            "title": "Sendinvitations",
            "description": "Send invitations to participants. When true, the API auto-detects the best channel (email or WhatsApp) for each participant.",
            "default": false
          },
          "sendByWhatsapp": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sendbywhatsapp",
            "description": "DEPRECATED: Channel is now auto-detected per participant when sendInvitations=true. Accepted for backward compatibility but ignored.",
            "deprecated": true
          },
          "sendByEmail": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sendbyemail",
            "description": "DEPRECATED: Channel is now auto-detected per participant when sendInvitations=true. Accepted for backward compatibility but ignored.",
            "deprecated": true
          },
          "startAtStep": {
            "type": "integer",
            "maximum": 3.0,
            "minimum": 1.0,
            "title": "Startatstep",
            "description": "Initial step (1=draft, 2=fields, 3=signatures)",
            "default": 1
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expiresat",
            "description": "Optional expiration deadline (ISO 8601). If set, the document will transition to EXPIRADO after this date."
          },
          "expirationReminders": {
            "anyOf": [
              {
                "items": {
                  "type": "integer"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expirationreminders",
            "description": "Days before expiration to send reminders (e.g., [1, 3, 7]). Each value must be 1-365. Max 10 entries."
          }
        },
        "type": "object",
        "title": "DocumentConfig",
        "description": "Configuración de documento."
      },
      "DocumentCreateRequestV2": {
        "properties": {
          "document": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentFile"
              },
              {
                "type": "null"
              }
            ],
            "description": "File content (base64). Required unless templateId is provided."
          },
          "templateId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Templateid",
            "description": "UUID of a DOCX template. When provided, the backend downloads the DOCX from S3 and uses it as the document source. Mutually exclusive with 'document'."
          },
          "templateValues": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Templatevalues",
            "description": "Key-value pairs to inject into the template's {{variables}}. Only used when templateId is provided.",
            "example": {
              "empresa": "Constantinopla S.A. de C.V.",
              "monto": "$150,000.00 MXN",
              "nombre_cliente": "Pedro Páramo"
            }
          },
          "placeholders": {
            "anyOf": [
              {
                "additionalProperties": {
                  "type": "string"
                },
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Placeholders",
            "description": "Key-value pairs to replace in DOCX documents (e.g., {{ client_name }} → 'Juan'). Only applied for .docx files; ignored for PDFs.",
            "example": {
              "empresa": "Constantinopla S.A. de C.V.",
              "fecha_contrato": "20 de febrero de 2026",
              "monto": "$150,000.00 MXN",
              "nombre_cliente": "Pedro Páramo",
              "rfc": "CPL210301XYZ"
            }
          },
          "participants": {
            "items": {
              "$ref": "#/components/schemas/DocumentParticipant"
            },
            "type": "array",
            "title": "Participants",
            "description": "List of participants (signers)"
          },
          "fields": {
            "items": {
              "$ref": "#/components/schemas/SignatureFieldCreate"
            },
            "type": "array",
            "title": "Fields",
            "description": "List of signature fields"
          },
          "signatureValidation": {
            "$ref": "#/components/schemas/DocumentValidationSettings",
            "description": "Signature validation settings"
          },
          "config": {
            "$ref": "#/components/schemas/DocumentConfig",
            "description": "Document configuration"
          },
          "permissions": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentPermissions"
              },
              {
                "type": "null"
              }
            ],
            "description": "Document permissions and ownership. If not specified, the API key owner is the document owner."
          },
          "folderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Folderid",
            "description": "Optional folder ID to organize the document"
          },
          "folderName": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Foldername",
            "description": "Folder name – finds existing folder or creates one. Ignored if folderId is also provided."
          }
        },
        "type": "object",
        "title": "DocumentCreateRequestV2",
        "description": "Request para crear documento V2 (Internal API).\n\nTwo modes:\n- Direct upload: provide `document` with base64Content\n- From template: provide `templateId` (and optional `templateValues`)"
      },
      "DocumentFile": {
        "properties": {
          "base64Content": {
            "type": "string",
            "minLength": 1,
            "title": "Base64Content",
            "description": "File content encoded in base64 (max 50MB before encoding)"
          },
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Name",
            "description": "Original filename with extension (e.g., 'contract.pdf')"
          }
        },
        "type": "object",
        "required": [
          "base64Content",
          "name"
        ],
        "title": "DocumentFile",
        "description": "File information for document creation."
      },
      "DocumentListV2Response": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "Request success status",
            "default": true
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "Response message",
            "default": "Documents retrieved successfully"
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/DocumentV2Response"
            },
            "type": "array",
            "title": "Data",
            "description": "Array of documents"
          },
          "meta": {
            "$ref": "#/components/schemas/PaginationMeta",
            "description": "Pagination metadata (total is null; use /v2/documents/total)"
          },
          "folders": {
            "anyOf": [
              {
                "items": {
                  "additionalProperties": true,
                  "type": "object"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Folders",
            "description": "Folders list (if includeFolders=true)"
          },
          "documentStats": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Documentstats",
            "description": "Aggregated document statistics (if includeDocumentStats=true)"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "DocumentListV2Response",
        "description": "Paginated list of documents with metadata and optional extras."
      },
      "DocumentParticipant": {
        "properties": {
          "email": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email",
            "description": "Participant email (optional if whatsapp provided)"
          },
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Name",
            "description": "Participant name"
          },
          "whatsapp": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Whatsapp",
            "description": "WhatsApp number (must start with +)"
          },
          "invitedBy": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Invitedby",
            "description": "Email of inviter"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "DocumentParticipant",
        "description": "Participant de documento.\n\nExactly one identifier (email or whatsapp) must be provided.\nEach participant uses a single notification channel."
      },
      "DocumentParticipantData2": {
        "properties": {
          "email": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Email"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "whatsapp": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Whatsapp"
          }
        },
        "type": "object",
        "title": "DocumentParticipantData2"
      },
      "DocumentPatchRequestV2": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "New document name"
          },
          "folderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Folderid",
            "description": "Folder ID to move document to (null to remove from folder)"
          },
          "config": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentConfig"
              },
              {
                "type": "null"
              }
            ],
            "description": "Document configuration updates"
          },
          "signatureValidation": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentValidationSettings"
              },
              {
                "type": "null"
              }
            ],
            "description": "Signature validation settings updates"
          },
          "permissions": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DocumentPermissions"
              },
              {
                "type": "null"
              }
            ],
            "description": "Document permissions updates"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status",
            "description": "Advance the document's signature state status. Only whitelisted transitions are allowed: RECOLECTANDO_FIRMANTES → SELLOS_PDF. Other status changes use dedicated endpoints (start-signing, enter-correction, exit-correction, void)."
          }
        },
        "type": "object",
        "title": "DocumentPatchRequestV2",
        "description": "Request for partial document updates (PATCH).\n\nAll fields are optional. Only provided fields will be updated.\nCommon use cases:\n- Move document to folder: {\"folderId\": \"uuid\"}\n- Rename document: {\"name\": \"New Name.pdf\"}\n- Update config: {\"config\": {...}}\n- Update permissions: {\"permissions\": {...}}\n- Advance document status: {\"status\": \"SELLOS_PDF\"}"
      },
      "DocumentPermissions": {
        "properties": {
          "ownerEmail": {
            "anyOf": [
              {
                "type": "string",
                "format": "email"
              },
              {
                "type": "null"
              }
            ],
            "title": "Owneremail",
            "description": "Email del propietario del documento. Si no se especifica, el propietario es el usuario del API key."
          },
          "collaborators": {
            "items": {
              "$ref": "#/components/schemas/Collaborator"
            },
            "type": "array",
            "title": "Collaborators",
            "description": "Lista de colaboradores con permisos específicos (lectura, edición, eliminación, etc.)"
          },
          "isPublicRead": {
            "type": "boolean",
            "title": "Ispublicread",
            "description": "Si el documento debe ser de lectura pública (sin autenticación requerida)",
            "default": false
          }
        },
        "type": "object",
        "title": "DocumentPermissions",
        "description": "Sistema de permisos granular para documentos.\n\nPermite especificar el propietario del documento y colaboradores con permisos específicos.\nLos firmantes (signers) se definen en el campo 'participants' del request principal."
      },
      "DocumentScopeEnum": {
        "type": "string",
        "enum": [
          "owner",
          "org",
          "tenant",
          "accessible"
        ],
        "title": "DocumentScopeEnum",
        "description": "Document scope for filtering.\n\nDefines the scope of documents to retrieve:\n- OWNER: Only documents where user is the creator (default)\n- ORG: All documents in user's organization\n- TENANT: All documents in user's tenant (multi-org admin scope)\n- ACCESSIBLE: All documents where user is owner OR participant"
      },
      "DocumentSigningContext": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "title": {
            "type": "string",
            "title": "Title"
          },
          "total_signers": {
            "type": "integer",
            "title": "Total Signers"
          },
          "signed_count": {
            "type": "integer",
            "title": "Signed Count"
          },
          "is_sealed": {
            "type": "boolean",
            "title": "Is Sealed"
          }
        },
        "type": "object",
        "required": [
          "id",
          "title",
          "total_signers",
          "signed_count",
          "is_sealed"
        ],
        "title": "DocumentSigningContext",
        "description": "Document context in a verify response — includes signing state that\nlets the integrator distinguish \"this signer is done\" from \"the whole\ndocument is sealed and evidence is available\".\n\n- total_signers: total number of signers on the document\n- signed_count: how many have already transitioned to SIGNED\n- is_sealed: true iff all signers are done AND evidence PDF exists"
      },
      "DocumentSortFieldEnum": {
        "type": "string",
        "enum": [
          "created_at",
          "updated_at",
          "name",
          "document_type"
        ],
        "title": "DocumentSortFieldEnum",
        "description": "Valid sort fields for documents."
      },
      "DocumentStatsV2Response": {
        "properties": {
          "totalDocuments": {
            "type": "integer",
            "title": "Totaldocuments",
            "description": "Total number of documents"
          },
          "totalCompleted": {
            "type": "integer",
            "title": "Totalcompleted",
            "description": "Documents with completed signature flow"
          },
          "totalPending": {
            "type": "integer",
            "title": "Totalpending",
            "description": "Documents waiting on signatures or processing"
          },
          "totalConfiguring": {
            "type": "integer",
            "title": "Totalconfiguring",
            "description": "Documents being configured before invitations are sent"
          },
          "recentCount": {
            "type": "integer",
            "title": "Recentcount",
            "description": "Documents created in last 7 days"
          }
        },
        "type": "object",
        "required": [
          "totalDocuments",
          "totalCompleted",
          "totalPending",
          "totalConfiguring",
          "recentCount"
        ],
        "title": "DocumentStatsV2Response",
        "description": "Statistics about user's documents.",
        "example": {
          "recentCount": 12,
          "totalCompleted": 42,
          "totalConfiguring": 15,
          "totalDocuments": 150,
          "totalPending": 93
        }
      },
      "DocumentSummary": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "title": {
            "type": "string",
            "title": "Title"
          }
        },
        "type": "object",
        "required": [
          "id",
          "title"
        ],
        "title": "DocumentSummary"
      },
      "DocumentV2Response": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Document UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Document name"
          },
          "documentType": {
            "type": "string",
            "title": "Documenttype",
            "description": "Document type"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat",
            "description": "Creation timestamp"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat",
            "description": "Last update timestamp"
          },
          "ownerId": {
            "type": "string",
            "title": "Ownerid",
            "description": "Owner user ID"
          },
          "orgId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orgid",
            "description": "Organization ID"
          },
          "categoryId": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Categoryid",
            "description": "Category ID"
          },
          "activePublicUrl": {
            "type": "boolean",
            "title": "Activepublicurl",
            "description": "Public URL status",
            "default": false
          },
          "chainId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Chainid",
            "description": "Document chain ID (null for standalone documents)"
          },
          "chainStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Chainstatus",
            "description": "Chain status (DRAFT, INVITED, FILLING, SIGNING, COMPLETED, VOIDED, EXPIRED)"
          },
          "signersData": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SignersData"
              },
              {
                "type": "null"
              }
            ],
            "description": "Signers and signatures information"
          },
          "folders": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/FolderSummary"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Folders",
            "description": "Folders that reference this document (includeFolders=true)"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "documentType",
          "createdAt",
          "updatedAt",
          "ownerId"
        ],
        "title": "DocumentV2Response",
        "description": "Single document response with camelCase aliases.",
        "example": {
          "activePublicUrl": false,
          "categoryId": 1,
          "createdAt": "2024-11-23T10:00:00Z",
          "documentType": "EDITABLE",
          "folders": [
            {
              "id": "111e8400-e29b-41d4-a716-446655440000",
              "name": "Contratos"
            }
          ],
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Contract 2024.pdf",
          "orgId": "550e8400-e29b-41d4-a716-446655440002",
          "ownerId": "550e8400-e29b-41d4-a716-446655440001",
          "signersData": {
            "id": "cdc27f13-4d05-47d0-9690-fb69d005e7f8",
            "signatures": [
              {
                "id": "63db6fa9-2709-4f68-9ea7-bc640194bade",
                "signer": {
                  "email": "soy@israelortiz.com",
                  "id": "99dc8f00-be5f-4331-ae66-db71bc2f6ccb"
                },
                "status": "SIGNED"
              }
            ],
            "status": "TODOS_FIRMARON"
          },
          "updatedAt": "2024-11-23T10:00:00Z"
        }
      },
      "DocumentValidationSettings": {
        "properties": {
          "FEA": {
            "type": "boolean",
            "title": "Fea",
            "description": "validation with mexican Firma Electronica Avanzada",
            "default": false
          },
          "eIDAS": {
            "type": "boolean",
            "title": "Eidas",
            "description": "eIDAS compliance",
            "default": false
          },
          "nom151": {
            "type": "boolean",
            "title": "Nom151",
            "description": "NOM-151 compliance",
            "default": false
          },
          "autografa": {
            "type": "boolean",
            "title": "Autografa",
            "description": "Autógrafa signature",
            "default": true
          },
          "id_scan": {
            "type": "boolean",
            "title": "Id Scan",
            "description": "Standalone ID scan (INE, passport, etc.)",
            "default": false
          },
          "biometric_signature": {
            "type": "boolean",
            "title": "Biometric Signature",
            "description": "Biometric selfie (face comparison against ID)",
            "default": false
          },
          "confirm_name_to_finish": {
            "type": "boolean",
            "title": "Confirm Name To Finish",
            "default": false
          },
          "ai_verification": {
            "type": "boolean",
            "title": "Ai Verification",
            "description": "Legacy catch-all — prefer modular flags below",
            "default": false
          },
          "videofirma": {
            "type": "boolean",
            "title": "Videofirma",
            "description": "Video recording of the signer during signing process",
            "default": false
          },
          "document_scan": {
            "type": "boolean",
            "title": "Document Scan",
            "description": "AI document classification + OCR extraction (GPT-4o)",
            "default": false
          },
          "name_verification": {
            "type": "boolean",
            "title": "Name Verification",
            "description": "MRZ extraction + cross-check name verification (FastMRZ, deterministic)",
            "default": false
          },
          "selfie_capture": {
            "type": "boolean",
            "title": "Selfie Capture",
            "description": "Capture selfie and verify it's a real face (no biometric comparison). Required if biometric_face_match is enabled.",
            "default": false
          },
          "biometric_face_match": {
            "type": "boolean",
            "title": "Biometric Face Match",
            "description": "Selfie + ArcFace biometric comparison against ID photo. Requires selfie_capture to be enabled.",
            "default": false
          },
          "deep_fake_shield": {
            "type": "boolean",
            "title": "Deep Fake Shield",
            "description": "Anti-fraud ML deepfake detection",
            "default": false
          },
          "anti_spoof_shield": {
            "type": "boolean",
            "title": "Anti Spoof Shield",
            "description": "Presentation attack detection (printed photos, screen replay)",
            "default": false
          },
          "id_reuse_policy": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Id Reuse Policy",
            "description": "Controls whether a signer's prior identity verification is reused. 'always_new' (default) always requests a fresh capture; 'auto' skips ID scan if a prior verification exists.",
            "default": "always_new"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "DocumentValidationSettings",
        "description": "Configuración de validaciones de firma."
      },
      "DocxTemplateDeleteResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "Whether the deletion succeeded",
            "default": true
          },
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Template UUID that was deleted"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Template name"
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "Human-readable result message"
          },
          "softDelete": {
            "type": "boolean",
            "title": "Softdelete",
            "description": "True if soft-deleted (marked inactive), False if hard-deleted",
            "default": true
          },
          "s3Deleted": {
            "type": "boolean",
            "title": "S3Deleted",
            "description": "Whether the underlying S3 file was removed",
            "default": false
          },
          "inUseBy": {
            "$ref": "#/components/schemas/TemplateDeleteUsage",
            "description": "Snapshot of references at deletion time"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "message"
        ],
        "title": "DocxTemplateDeleteResponse",
        "description": "Response after a successful template deletion."
      },
      "DocxTemplateDetailResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Template UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Template name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "description": "Template description"
          },
          "originalFilename": {
            "type": "string",
            "title": "Originalfilename",
            "description": "Original uploaded filename"
          },
          "fileType": {
            "type": "string",
            "title": "Filetype",
            "description": "File type"
          },
          "variables": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Variables",
            "description": "Variable names (flat list)"
          },
          "variableConfig": {
            "items": {
              "$ref": "#/components/schemas/VariableConfigItem"
            },
            "type": "array",
            "title": "Variableconfig",
            "description": "Rich variable metadata"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "description": "User-defined tags"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category",
            "description": "Template category"
          },
          "aiEditable": {
            "type": "boolean",
            "title": "Aieditable",
            "default": true
          },
          "usageCount": {
            "type": "integer",
            "title": "Usagecount",
            "default": 0
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lastusedat"
          },
          "currentVersion": {
            "type": "integer",
            "title": "Currentversion",
            "description": "Current active version number",
            "default": 1
          },
          "testDataSets": {
            "items": {
              "$ref": "#/components/schemas/TestDataSetResponse"
            },
            "type": "array",
            "title": "Testdatasets",
            "description": "Predefined test data sets for preview"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "originalFilename",
          "fileType",
          "createdAt",
          "updatedAt"
        ],
        "title": "DocxTemplateDetailResponse",
        "description": "Full detail response for a single template."
      },
      "DocxTemplateListResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/DocxTemplateSummary"
            },
            "type": "array",
            "title": "Data",
            "description": "Array of templates"
          },
          "total": {
            "type": "integer",
            "title": "Total",
            "description": "Total number of templates"
          }
        },
        "type": "object",
        "required": [
          "data",
          "total"
        ],
        "title": "DocxTemplateListResponse",
        "description": "Paginated list of templates."
      },
      "DocxTemplateSummary": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Template UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Template name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "description": "Template description"
          },
          "originalFilename": {
            "type": "string",
            "title": "Originalfilename",
            "description": "Original uploaded filename"
          },
          "fileType": {
            "type": "string",
            "title": "Filetype",
            "description": "File type: 'docx' or 'pdf'"
          },
          "variableCount": {
            "type": "integer",
            "title": "Variablecount",
            "description": "Number of detected variables"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "description": "User-defined tags"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category",
            "description": "Template category"
          },
          "aiEditable": {
            "type": "boolean",
            "title": "Aieditable",
            "description": "AI editing enabled",
            "default": true
          },
          "usageCount": {
            "type": "integer",
            "title": "Usagecount",
            "description": "Documents created from this template",
            "default": 0
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lastusedat",
            "description": "Last time a document was created"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "originalFilename",
          "fileType",
          "variableCount",
          "createdAt",
          "updatedAt"
        ],
        "title": "DocxTemplateSummary",
        "description": "Summary view of a template for list endpoints."
      },
      "DocxTemplateUpdateRequest": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "tags": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tags",
            "description": "Replace tags entirely"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category",
            "description": "Template category"
          },
          "aiEditable": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Aieditable"
          },
          "variableConfig": {
            "anyOf": [
              {
                "items": {
                  "$ref": "#/components/schemas/VariableConfigItem"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Variableconfig",
            "description": "Override auto-generated variable metadata"
          }
        },
        "type": "object",
        "title": "DocxTemplateUpdateRequest",
        "description": "Request to update template metadata (PATCH)."
      },
      "DocxTemplateUploadResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Template UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Template name"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description",
            "description": "Template description"
          },
          "originalFilename": {
            "type": "string",
            "title": "Originalfilename",
            "description": "Original uploaded filename"
          },
          "fileType": {
            "type": "string",
            "title": "Filetype",
            "description": "File type: 'docx' or 'pdf'"
          },
          "variables": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Variables",
            "description": "Auto-detected Jinja2 variable names from the DOCX"
          },
          "variableConfig": {
            "items": {
              "$ref": "#/components/schemas/VariableConfigItem"
            },
            "type": "array",
            "title": "Variableconfig",
            "description": "Rich variable metadata with types and labels"
          },
          "tags": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Tags",
            "description": "User-defined tags"
          },
          "category": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Category",
            "description": "Template category"
          },
          "aiEditable": {
            "type": "boolean",
            "title": "Aieditable",
            "description": "AI editing enabled",
            "default": true
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat",
            "description": "Creation timestamp"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "originalFilename",
          "fileType",
          "createdAt"
        ],
        "title": "DocxTemplateUploadResponse",
        "description": "Response after uploading a DOCX template."
      },
      "DocxTemplateVariablesResponse": {
        "properties": {
          "templateId": {
            "type": "string",
            "title": "Templateid",
            "description": "Template UUID"
          },
          "templateName": {
            "type": "string",
            "title": "Templatename",
            "description": "Template name"
          },
          "variables": {
            "items": {
              "$ref": "#/components/schemas/TemplateVariableInfo"
            },
            "type": "array",
            "title": "Variables",
            "description": "Detected variables with labels and types"
          }
        },
        "type": "object",
        "required": [
          "templateId",
          "templateName"
        ],
        "title": "DocxTemplateVariablesResponse",
        "description": "Response with detected variables for a template."
      },
      "EvidenceBundle": {
        "properties": {
          "available": {
            "type": "boolean",
            "title": "Available"
          },
          "evidence_pdf": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EvidencePdfInfo"
              },
              {
                "type": "null"
              }
            ]
          },
          "nom_151": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Nom151Info"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "type": "object",
        "required": [
          "available"
        ],
        "title": "EvidenceBundle",
        "description": "Evidence bundle attached to a verify response.\n\n`available` is true only when the document is fully signed AND the\nTemporal workflow has finished writing the evidence PDF to S3. For\ndocuments with pending signers or for the brief race window while the\nworkflow runs, `available=false` and both fields are null."
      },
      "EvidencePdfInfo": {
        "properties": {
          "s3_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "S3 Key"
          },
          "presigned_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Presigned Url"
          },
          "hash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Hash"
          }
        },
        "type": "object",
        "required": [
          "s3_key",
          "presigned_url"
        ],
        "title": "EvidencePdfInfo"
      },
      "ExistingContactInfo": {
        "properties": {
          "contactId": {
            "type": "string",
            "title": "Contactid"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "identityVerified": {
            "type": "boolean",
            "title": "Identityverified",
            "default": false
          },
          "identityVerifiedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Identityverifiedat"
          }
        },
        "type": "object",
        "required": [
          "contactId"
        ],
        "title": "ExistingContactInfo",
        "description": "Info about an existing contact for duplicate detection."
      },
      "ExplicitFieldPlacement": {
        "properties": {
          "templateId": {
            "type": "string",
            "title": "Templateid",
            "description": "Which template/document this field belongs to"
          },
          "roleName": {
            "type": "string",
            "title": "Rolename",
            "description": "Role this field is assigned to"
          },
          "pageIndex": {
            "type": "integer",
            "title": "Pageindex",
            "description": "Zero-based page index",
            "default": 0
          },
          "x": {
            "type": "number",
            "title": "X"
          },
          "y": {
            "type": "number",
            "title": "Y"
          },
          "width": {
            "type": "number",
            "title": "Width",
            "default": 200
          },
          "height": {
            "type": "number",
            "title": "Height",
            "default": 60
          },
          "type": {
            "type": "string",
            "title": "Type",
            "description": "signatureField | initials | stamp | checkbox",
            "default": "signatureField"
          },
          "originWidth": {
            "type": "number",
            "title": "Originwidth",
            "description": "Page width used for x/y reference",
            "default": 612
          },
          "originHeight": {
            "type": "number",
            "title": "Originheight",
            "description": "Page height used for x/y reference",
            "default": 792
          },
          "includeInAllPages": {
            "type": "boolean",
            "title": "Includeinallpages",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "templateId",
          "roleName",
          "x",
          "y"
        ],
        "title": "ExplicitFieldPlacement",
        "description": "Explicit per-document, per-role signature field placement.\n\nUsed by the chain wizard's visual field editor: the admin places\nboxes on a preview PDF and we persist them as DocumentField rows\nwhen the chain is created. Coordinates are pixels relative to\n`originWidth` × `originHeight` (the rendered PDF page size)."
      },
      "ExtendDeadlineRequest": {
        "properties": {
          "newExpiresAt": {
            "type": "string",
            "format": "date-time",
            "title": "Newexpiresat",
            "description": "New expiration deadline (ISO 8601). Must be in the future."
          }
        },
        "type": "object",
        "required": [
          "newExpiresAt"
        ],
        "title": "ExtendDeadlineRequest",
        "description": "Request to extend a document's signing deadline."
      },
      "ExtendDeadlineResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "newExpiresAt": {
            "type": "string",
            "title": "Newexpiresat"
          },
          "extendedCount": {
            "type": "integer",
            "title": "Extendedcount"
          },
          "previousStatus": {
            "type": "string",
            "title": "Previousstatus"
          },
          "newStatus": {
            "type": "string",
            "title": "Newstatus"
          }
        },
        "type": "object",
        "required": [
          "success",
          "newExpiresAt",
          "extendedCount",
          "previousStatus",
          "newStatus"
        ],
        "title": "ExtendDeadlineResponse",
        "description": "Response after extending a document's deadline."
      },
      "FieldPosition": {
        "properties": {
          "x": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "X"
          },
          "y": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Y"
          }
        },
        "type": "object",
        "title": "FieldPosition"
      },
      "FileUploadRequest": {
        "properties": {
          "key": {
            "type": "string",
            "title": "Key",
            "description": "S3 object key (must start with 'signatures/')",
            "examples": [
              "signatures/abc-123/biometric/1707900000.jpg"
            ]
          },
          "content": {
            "type": "string",
            "title": "Content",
            "description": "Base64-encoded file content"
          },
          "contentType": {
            "type": "string",
            "title": "Contenttype",
            "description": "MIME type of the file",
            "default": "application/octet-stream",
            "examples": [
              "image/jpeg",
              "image/png",
              "application/pdf"
            ]
          }
        },
        "type": "object",
        "required": [
          "key",
          "content"
        ],
        "title": "FileUploadRequest",
        "description": "Request body for file upload."
      },
      "FileUploadResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "s3Key": {
            "type": "string",
            "title": "S3Key"
          }
        },
        "type": "object",
        "required": [
          "s3Key"
        ],
        "title": "FileUploadResponse",
        "description": "Response after successful upload."
      },
      "FillVariableItem": {
        "properties": {
          "variableName": {
            "type": "string",
            "title": "Variablename"
          },
          "value": {
            "type": "string",
            "title": "Value"
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "manual"
          }
        },
        "type": "object",
        "required": [
          "variableName",
          "value"
        ],
        "title": "FillVariableItem",
        "description": "Single variable value submission."
      },
      "FillVariablesRequest": {
        "properties": {
          "roleId": {
            "type": "string",
            "title": "Roleid"
          },
          "variables": {
            "items": {
              "$ref": "#/components/schemas/FillVariableItem"
            },
            "type": "array",
            "title": "Variables"
          }
        },
        "type": "object",
        "required": [
          "roleId",
          "variables"
        ],
        "title": "FillVariablesRequest",
        "description": "POST /v2/chains/{id}/fill-variables — fill variables for a role."
      },
      "FillVariablesResponse": {
        "properties": {
          "filledCount": {
            "type": "integer",
            "title": "Filledcount"
          },
          "remainingCount": {
            "type": "integer",
            "title": "Remainingcount"
          },
          "chainStatus": {
            "type": "string",
            "title": "Chainstatus"
          },
          "allFilled": {
            "type": "boolean",
            "title": "Allfilled"
          }
        },
        "type": "object",
        "required": [
          "filledCount",
          "remainingCount",
          "chainStatus",
          "allFilled"
        ],
        "title": "FillVariablesResponse"
      },
      "FolderCreateRequest": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Name",
            "description": "Folder name"
          },
          "parentId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parentid",
            "description": "Parent folder ID (null = root level)"
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "FolderCreateRequest",
        "description": "Create new folder.",
        "example": {
          "name": "Facturas 2024",
          "parentId": "550e8400-e29b-41d4-a716-446655440000"
        }
      },
      "FolderListResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "Request success status",
            "default": true
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "Response message",
            "default": "Folders retrieved successfully"
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/FolderTreeResponse"
            },
            "type": "array",
            "title": "Data",
            "description": "Array of folders in tree structure"
          }
        },
        "type": "object",
        "required": [
          "data"
        ],
        "title": "FolderListResponse",
        "description": "List of folders response."
      },
      "FolderSummary": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Folder UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Folder name"
          },
          "parentId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parentid",
            "description": "Parent folder UUID"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name"
        ],
        "title": "FolderSummary",
        "description": "Minimal folder info to embed inside document payloads."
      },
      "FolderTreeResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Folder UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Folder name"
          },
          "ownerId": {
            "type": "string",
            "title": "Ownerid",
            "description": "Owner user ID"
          },
          "tenantId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tenantid",
            "description": "Tenant ID (null = personal folder)"
          },
          "parentId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parentid",
            "description": "Parent folder ID"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat",
            "description": "Creation timestamp"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat",
            "description": "Last update timestamp"
          },
          "hasDocs": {
            "type": "boolean",
            "title": "Hasdocs",
            "description": "If folder has docs"
          },
          "isMain": {
            "type": "boolean",
            "title": "Ismain",
            "description": "Is this the main/root folder?",
            "default": false
          },
          "subfolders": {
            "items": {
              "$ref": "#/components/schemas/FolderTreeResponse"
            },
            "type": "array",
            "title": "Subfolders",
            "description": "Child folders (recursive)"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "ownerId",
          "createdAt",
          "updatedAt",
          "hasDocs"
        ],
        "title": "FolderTreeResponse",
        "description": "Folder with hierarchical structure (tree).",
        "example": {
          "createdAt": "2024-11-23T10:00:00Z",
          "hasDocs": true,
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "isMain": true,
          "name": "Documentos",
          "ownerId": "550e8400-e29b-41d4-a716-446655440001",
          "subfolders": [
            {
              "createdAt": "2024-11-23T10:00:00Z",
              "hasDocs": false,
              "id": "550e8400-e29b-41d4-a716-446655440002",
              "isMain": false,
              "name": "Contratos",
              "ownerId": "550e8400-e29b-41d4-a716-446655440001",
              "parentId": "550e8400-e29b-41d4-a716-446655440000",
              "subfolders": [],
              "updatedAt": "2024-11-23T10:00:00Z"
            }
          ],
          "updatedAt": "2024-11-23T10:00:00Z"
        }
      },
      "FolderUpdateRequest": {
        "properties": {
          "name": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 255,
                "minLength": 1
              },
              {
                "type": "null"
              }
            ],
            "title": "Name",
            "description": "New folder name"
          },
          "parentId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parentid",
            "description": "New parent folder ID (to move folder)"
          }
        },
        "type": "object",
        "title": "FolderUpdateRequest",
        "description": "Rename or move folder.",
        "example": {
          "name": "Contratos 2025",
          "parentId": "550e8400-e29b-41d4-a716-446655440001"
        }
      },
      "FolderV2Response": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Folder UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Folder name"
          },
          "ownerId": {
            "type": "string",
            "title": "Ownerid",
            "description": "Owner user ID"
          },
          "tenantId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tenantid",
            "description": "Tenant ID (null = personal folder)"
          },
          "parentId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parentid",
            "description": "Parent folder ID (null = root)"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat",
            "description": "Creation timestamp"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "title": "Updatedat",
            "description": "Last update timestamp"
          },
          "hasDocs": {
            "type": "boolean",
            "title": "Hasdocs",
            "description": "If folder has docs"
          },
          "isMain": {
            "type": "boolean",
            "title": "Ismain",
            "description": "Is this the main/root folder?",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "ownerId",
          "createdAt",
          "updatedAt",
          "hasDocs"
        ],
        "title": "FolderV2Response",
        "description": "Single folder response without children.",
        "example": {
          "createdAt": "2024-11-23T10:00:00Z",
          "hasDocs": true,
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "isMain": true,
          "name": "Contratos 2024",
          "ownerId": "550e8400-e29b-41d4-a716-446655440001",
          "tenantId": "550e8400-e29b-41d4-a716-446655440099",
          "updatedAt": "2024-11-23T10:00:00Z"
        }
      },
      "FunnelStepResponse": {
        "properties": {
          "label": {
            "type": "string",
            "title": "Label",
            "description": "Stage label"
          },
          "count": {
            "type": "integer",
            "title": "Count",
            "description": "Document count at this stage"
          },
          "pct": {
            "type": "number",
            "title": "Pct",
            "description": "Percentage of total"
          }
        },
        "type": "object",
        "required": [
          "label",
          "count",
          "pct"
        ],
        "title": "FunnelStepResponse",
        "description": "One stage in the signing funnel."
      },
      "GuestChainRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "Raw guest token from the signing link URL"
          }
        },
        "type": "object",
        "required": [
          "token"
        ],
        "title": "GuestChainRequest",
        "description": "Base request — just the token."
      },
      "GuestDocContentRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "Raw guest token"
          },
          "documentId": {
            "type": "string",
            "title": "Documentid",
            "description": "Document UUID within the chain"
          }
        },
        "type": "object",
        "required": [
          "token",
          "documentId"
        ],
        "title": "GuestDocContentRequest",
        "description": "Request to get structured text of a document in the chain."
      },
      "GuestFillItem": {
        "properties": {
          "variableName": {
            "type": "string",
            "title": "Variablename"
          },
          "value": {
            "type": "string",
            "title": "Value"
          },
          "source": {
            "type": "string",
            "title": "Source",
            "default": "manual"
          }
        },
        "type": "object",
        "required": [
          "variableName",
          "value"
        ],
        "title": "GuestFillItem",
        "description": "Single variable fill."
      },
      "GuestFillRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "Raw guest token"
          },
          "variables": {
            "items": {
              "$ref": "#/components/schemas/GuestFillItem"
            },
            "type": "array",
            "title": "Variables"
          }
        },
        "type": "object",
        "required": [
          "token",
          "variables"
        ],
        "title": "GuestFillRequest",
        "description": "Fill variables for the guest's role."
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "InitDocumentSummary": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "title": {
            "type": "string",
            "title": "Title"
          }
        },
        "type": "object",
        "required": [
          "id",
          "title"
        ],
        "title": "InitDocumentSummary"
      },
      "InitRequest": {
        "properties": {
          "client_secret": {
            "type": "string",
            "minLength": 10,
            "title": "Client Secret",
            "description": "The client_secret received via postMessage from the integrator SDK. Format: as_sess_{session_id}_secret_{random}"
          },
          "parent_origin": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Parent Origin",
            "description": "The origin of the window embedding the iframe, e.g. 'https://integrator.com'. If the session has allowed_origins configured, this must be in the list."
          }
        },
        "type": "object",
        "required": [
          "client_secret"
        ],
        "title": "InitRequest",
        "description": "Body for POST /v2/signing-sessions/init."
      },
      "InitResponse": {
        "properties": {
          "session_id": {
            "type": "string",
            "title": "Session Id",
            "description": "UUID of the EmbeddedSigningSession."
          },
          "signature_id": {
            "type": "string",
            "title": "Signature Id",
            "description": "UUID of the Signature row."
          },
          "guest_token": {
            "type": "string",
            "title": "Guest Token",
            "description": "A fresh plaintext guest token. The iframe shell uses this to drive the existing signing pipeline (OTP verification, signing, confirmation). This token is rotated on every successful init, so a replay of the same client_secret would yield a different token."
          },
          "signer": {
            "$ref": "#/components/schemas/InitSignerSummary"
          },
          "document": {
            "$ref": "#/components/schemas/InitDocumentSummary"
          },
          "test_mode": {
            "type": "boolean",
            "title": "Test Mode"
          },
          "brand_profile_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Brand Profile Id"
          },
          "locale": {
            "type": "string",
            "title": "Locale"
          },
          "success_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Success Url",
            "description": "If set, the integrator should redirect the user here after signing completes."
          },
          "cancel_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cancel Url",
            "description": "If set, the integrator should redirect the user here after cancellation."
          }
        },
        "type": "object",
        "required": [
          "session_id",
          "signature_id",
          "guest_token",
          "signer",
          "document",
          "test_mode",
          "locale"
        ],
        "title": "InitResponse",
        "description": "Response body for POST /v2/signing-sessions/init."
      },
      "InitSignerSummary": {
        "properties": {
          "email": {
            "type": "string",
            "title": "Email"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "email",
          "name"
        ],
        "title": "InitSignerSummary"
      },
      "InputModeEnum": {
        "type": "string",
        "enum": [
          "free",
          "optional",
          "required"
        ],
        "title": "InputModeEnum"
      },
      "InviteRequestV2": {
        "properties": {
          "participant": {
            "$ref": "#/components/schemas/DocumentParticipantData2",
            "description": "Participant to invite (email, name, whatsapp)."
          },
          "config": {
            "$ref": "#/components/schemas/ParticipantConfig",
            "description": "Delivery config (email / whatsapp / invitedByEmail)."
          }
        },
        "type": "object",
        "required": [
          "participant",
          "config"
        ],
        "title": "InviteRequestV2",
        "description": "Body for the single-invite endpoint."
      },
      "InviteResponseV2": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "sentCount": {
            "type": "integer",
            "title": "Sentcount",
            "default": 0
          },
          "failedCount": {
            "type": "integer",
            "title": "Failedcount",
            "default": 0
          },
          "details": {
            "items": {
              "$ref": "#/components/schemas/InviteResultDetail"
            },
            "type": "array",
            "title": "Details",
            "default": []
          }
        },
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "title": "InviteResponseV2"
      },
      "InviteResultDetail": {
        "properties": {
          "participant": {
            "type": "string",
            "title": "Participant"
          },
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "guestLink": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Guestlink"
          }
        },
        "type": "object",
        "required": [
          "participant",
          "success"
        ],
        "title": "InviteResultDetail"
      },
      "MonthlyTrendResponse": {
        "properties": {
          "month": {
            "type": "string",
            "title": "Month",
            "description": "Month abbreviation (e.g. 'Jan')"
          },
          "signed": {
            "type": "integer",
            "title": "Signed",
            "description": "Number of fully signed documents"
          },
          "avgHours": {
            "type": "number",
            "title": "Avghours",
            "description": "Average signing time (hours)"
          }
        },
        "type": "object",
        "required": [
          "month",
          "signed",
          "avgHours"
        ],
        "title": "MonthlyTrendResponse",
        "description": "Signed documents and average signing hours per month."
      },
      "Nom151Info": {
        "properties": {
          "s3_key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "S3 Key"
          },
          "presigned_url": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Presigned Url"
          },
          "data": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Data"
          }
        },
        "type": "object",
        "required": [
          "s3_key",
          "presigned_url"
        ],
        "title": "Nom151Info"
      },
      "OCSPStatus": {
        "type": "string",
        "enum": [
          "valid",
          "revoked",
          "unknown",
          "error"
        ],
        "title": "OCSPStatus",
        "description": "OCSP verification result statuses."
      },
      "OCSPVerifyResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "status": {
            "$ref": "#/components/schemas/OCSPStatus",
            "description": "Estado OCSP del certificado"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "details": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Details",
            "description": "Detalles adicionales de la verificación"
          }
        },
        "type": "object",
        "required": [
          "status",
          "message"
        ],
        "title": "OCSPVerifyResponse",
        "description": "Result of OCSP certificate verification."
      },
      "OnboardingBranding": {
        "properties": {
          "logoUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Logourl"
          },
          "primaryColor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Primarycolor"
          },
          "companyName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Companyname"
          }
        },
        "type": "object",
        "title": "OnboardingBranding",
        "description": "Branding configuration for the onboarding shell."
      },
      "OnboardingConfig": {
        "properties": {
          "documentTypes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Documenttypes",
            "description": "Accepted document types: ine, passport",
            "default": [
              "ine",
              "passport"
            ]
          },
          "documentScan": {
            "type": "boolean",
            "title": "Documentscan",
            "description": "AI document classification — identifies doc type, validates structure",
            "default": false
          },
          "nameVerification": {
            "type": "boolean",
            "title": "Nameverification",
            "description": "MRZ extraction — extracts name from ID, verifies identity, saves to profile",
            "default": false
          },
          "biometricFaceMatch": {
            "type": "boolean",
            "title": "Biometricfacematch",
            "description": "Selfie capture + DeepFace ArcFace biometric match against ID photo. Requires selfie_capture.",
            "default": false
          },
          "selfieCapture": {
            "type": "boolean",
            "title": "Selfiecapture",
            "description": "Capture selfie only (face detection, no biometric match against ID)",
            "default": false
          },
          "deepFakeShield": {
            "type": "boolean",
            "title": "Deepfakeshield",
            "description": "Anti-fraud ML deepfake detection",
            "default": false
          },
          "antiSpoofShield": {
            "type": "boolean",
            "title": "Antispoofshield",
            "description": "Presentation attack detection (printed photos, screen replay)",
            "default": false
          },
          "requireSelfie": {
            "type": "boolean",
            "title": "Requireselfie",
            "default": false
          },
          "requireLiveness": {
            "type": "boolean",
            "title": "Requireliveness",
            "default": false
          },
          "requestTypedName": {
            "type": "boolean",
            "title": "Requesttypedname",
            "default": false
          },
          "requestVideoSignature": {
            "type": "boolean",
            "title": "Requestvideosignature",
            "default": false
          },
          "requestHumanReview": {
            "type": "boolean",
            "title": "Requesthumanreview",
            "default": false
          },
          "checkSynthId": {
            "type": "boolean",
            "title": "Checksynthid",
            "default": false
          },
          "aiVerification": {
            "type": "boolean",
            "title": "Aiverification",
            "default": false
          },
          "branding": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/OnboardingBranding"
              },
              {
                "type": "null"
              }
            ]
          },
          "callbackUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Callbackurl"
          },
          "redirectUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Redirecturl"
          }
        },
        "additionalProperties": true,
        "type": "object",
        "title": "OnboardingConfig",
        "description": "Configuration for an onboarding session.\n\n4 independently billable verification capabilities:\n- document_scan:         AI document classification (GPT-4o)\n- name_verification:     MRZ extraction + name verification (FastMRZ, deterministic)\n- biometric_face_match:  Selfie + DeepFace biometric comparison\n- deep_fake_shield:      Anti-fraud ML detection (future)"
      },
      "OnboardingResultCapture": {
        "properties": {
          "captureType": {
            "type": "string",
            "title": "Capturetype",
            "description": "id_front, id_back, selfie, liveness, video"
          },
          "imageUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Imageurl",
            "description": "Presigned S3 URL (1h TTL)"
          },
          "verificationStatus": {
            "type": "string",
            "title": "Verificationstatus",
            "description": "passed, failed, pending, skipped, error"
          },
          "verificationResult": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verificationresult"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "captureType",
          "verificationStatus",
          "createdAt"
        ],
        "title": "OnboardingResultCapture",
        "description": "A single capture with a presigned URL for the results endpoint."
      },
      "OnboardingResultResponse": {
        "properties": {
          "sessionId": {
            "type": "string",
            "title": "Sessionid"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "targetEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetemail"
          },
          "targetName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetname"
          },
          "verified": {
            "type": "boolean",
            "title": "Verified",
            "description": "True if session status is 'completed'"
          },
          "verifiedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verifiedat"
          },
          "documentType": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Documenttype",
            "description": "ine, passport, etc."
          },
          "extractedName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Extractedname"
          },
          "resultData": {
            "additionalProperties": true,
            "type": "object",
            "title": "Resultdata"
          },
          "captures": {
            "items": {
              "$ref": "#/components/schemas/OnboardingResultCapture"
            },
            "type": "array",
            "title": "Captures"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "completedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completedat"
          }
        },
        "type": "object",
        "required": [
          "sessionId",
          "status",
          "verified",
          "createdAt"
        ],
        "title": "OnboardingResultResponse",
        "description": "Authenticated response with full session results and presigned capture URLs."
      },
      "OnboardingSessionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "token": {
            "type": "string",
            "title": "Token"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "targetEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetemail"
          },
          "targetName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetname"
          },
          "config": {
            "additionalProperties": true,
            "type": "object",
            "title": "Config",
            "default": {}
          },
          "url": {
            "type": "string",
            "title": "Url",
            "description": "Public URL for this onboarding session"
          },
          "expiresAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expiresat"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          },
          "existingContact": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/ExistingContactInfo"
              },
              {
                "type": "null"
              }
            ],
            "description": "Present if email already belongs to an existing contact"
          }
        },
        "type": "object",
        "required": [
          "id",
          "token",
          "status",
          "url",
          "createdAt"
        ],
        "title": "OnboardingSessionResponse",
        "description": "Response after creating or fetching a session."
      },
      "OnboardingStatusResponse": {
        "properties": {
          "sessionId": {
            "type": "string",
            "title": "Sessionid"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "captures": {
            "items": {
              "$ref": "#/components/schemas/CaptureResult"
            },
            "type": "array",
            "title": "Captures",
            "default": []
          },
          "resultData": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Resultdata"
          },
          "completedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completedat"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "sessionId",
          "status"
        ],
        "title": "OnboardingStatusResponse",
        "description": "Response for polling the onboarding session status."
      },
      "OtpSendRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "The raw guest token from the signing link URL."
          },
          "delivery_method": {
            "type": "string",
            "title": "Delivery Method",
            "description": "Channel to send the OTP: 'whatsapp' or 'email'.",
            "default": "email"
          }
        },
        "type": "object",
        "required": [
          "token"
        ],
        "title": "OtpSendRequest",
        "description": "Request body for sending an OTP."
      },
      "OtpSendResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "delivery_method": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Delivery Method"
          },
          "expires_in_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires In Seconds"
          },
          "cooldown_remaining": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cooldown Remaining"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "OtpSendResponse"
      },
      "OtpVerifyRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "The raw guest token from the signing link URL."
          },
          "code": {
            "type": "string",
            "maxLength": 6,
            "minLength": 6,
            "title": "Code",
            "description": "The 6-digit OTP code entered by the guest."
          }
        },
        "type": "object",
        "required": [
          "token",
          "code"
        ],
        "title": "OtpVerifyRequest",
        "description": "Request body for verifying an OTP."
      },
      "OtpVerifyResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "attempts_remaining": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Attempts Remaining"
          },
          "locked": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Locked"
          },
          "already_verified": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Already Verified"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "OtpVerifyResponse"
      },
      "OwnerFixedValue": {
        "properties": {
          "variableName": {
            "type": "string",
            "title": "Variablename"
          },
          "value": {
            "type": "string",
            "title": "Value"
          }
        },
        "type": "object",
        "required": [
          "variableName",
          "value"
        ],
        "title": "OwnerFixedValue",
        "description": "Owner-provided fixed value for a variable."
      },
      "PaginationMeta": {
        "properties": {
          "limit": {
            "type": "integer",
            "maximum": 100.0,
            "minimum": 1.0,
            "title": "Limit",
            "description": "Items per page"
          },
          "total": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0.0
              },
              {
                "type": "null"
              }
            ],
            "title": "Total",
            "description": "Total number of items (null when totals are fetched via /v2/documents/total)"
          },
          "hasNext": {
            "type": "boolean",
            "title": "Hasnext",
            "description": "Whether there's a next page"
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Nextcursor",
            "description": "Cursor for next page"
          },
          "prevCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Prevcursor",
            "description": "Cursor for previous page"
          }
        },
        "type": "object",
        "required": [
          "limit",
          "hasNext"
        ],
        "title": "PaginationMeta",
        "description": "Pagination metadata for cursor-only responses.",
        "examples": [
          {
            "title": "Cursor-based pagination",
            "value": {
              "hasNext": true,
              "limit": 20,
              "nextCursor": "550e8400-e29b-41d4-a716-446655440000"
            }
          }
        ]
      },
      "ParticipantConfig": {
        "properties": {
          "sendInvitationByWhatsapp": {
            "type": "boolean",
            "title": "Sendinvitationbywhatsapp",
            "description": "DEPRECATED — channel is auto-determined per participant. Accepted but ignored.",
            "default": false
          },
          "sendInvitationByEmail": {
            "type": "boolean",
            "title": "Sendinvitationbyemail",
            "description": "DEPRECATED — channel is auto-determined per participant. Accepted but ignored.",
            "default": false
          },
          "invitedByEmail": {
            "type": "string",
            "title": "Invitedbyemail",
            "description": "The email of the user adding all the participants."
          },
          "invitedByName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Invitedbyname",
            "description": "Display name of the inviter (shown in email subject/body instead of raw email)."
          },
          "signingMode": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signingmode",
            "description": "The signing mode of the document (Simple or Autógrafa) to customize invitation copy."
          }
        },
        "type": "object",
        "required": [
          "invitedByEmail"
        ],
        "title": "ParticipantConfig"
      },
      "PermissionType": {
        "type": "string",
        "enum": [
          "read",
          "update",
          "delete",
          "sign",
          "admin"
        ],
        "title": "PermissionType",
        "description": "Tipos de permisos disponibles para colaboradores."
      },
      "PolicyResponse": {
        "properties": {
          "session_id": {
            "type": "string",
            "title": "Session Id"
          },
          "allowed_origins": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Allowed Origins",
            "description": "List of origins authorized to embed this session. Empty list means 'any origin' (wildcard). The dashboard injects these into Content-Security-Policy: frame-ancestors when serving the iframe HTML."
          },
          "frame_ancestors": {
            "type": "string",
            "title": "Frame Ancestors",
            "description": "Pre-built CSP frame-ancestors directive value. If allowed_origins is empty, this is '*'. Otherwise it is a space-separated list of origins."
          }
        },
        "type": "object",
        "required": [
          "session_id",
          "allowed_origins",
          "frame_ancestors"
        ],
        "title": "PolicyResponse",
        "description": "CSP hint for the dashboard Next.js route that serves the iframe."
      },
      "PriorVerificationCapture": {
        "properties": {
          "captureType": {
            "type": "string",
            "title": "Capturetype"
          },
          "s3Key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "S3Key"
          },
          "verificationStatus": {
            "type": "string",
            "title": "Verificationstatus"
          }
        },
        "type": "object",
        "required": [
          "captureType",
          "verificationStatus"
        ],
        "title": "PriorVerificationCapture",
        "description": "A single capture from a prior onboarding session."
      },
      "PriorVerificationResponse": {
        "properties": {
          "verified": {
            "type": "boolean",
            "title": "Verified",
            "default": false
          },
          "verifiedAt": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Verifiedat"
          },
          "onboardingSessionId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Onboardingsessionid"
          },
          "captures": {
            "items": {
              "$ref": "#/components/schemas/PriorVerificationCapture"
            },
            "type": "array",
            "title": "Captures"
          }
        },
        "type": "object",
        "title": "PriorVerificationResponse",
        "description": "Response for prior verification lookup."
      },
      "RecentEventResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "documentName": {
            "type": "string",
            "title": "Documentname"
          },
          "eventType": {
            "type": "string",
            "title": "Eventtype"
          },
          "actorName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Actorname"
          },
          "actorInitials": {
            "type": "string",
            "title": "Actorinitials"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "documentName",
          "eventType",
          "actorInitials",
          "createdAt"
        ],
        "title": "RecentEventResponse",
        "description": "A recent document event for the tenant activity feed."
      },
      "RegenerateChainPdfResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "chainId": {
            "type": "string",
            "title": "Chainid"
          },
          "documentId": {
            "type": "string",
            "title": "Documentid"
          },
          "chainStatus": {
            "type": "string",
            "title": "Chainstatus",
            "description": "Chain.status after the regen merged its result. SIGNING when every doc is now SUCCESS; FILLING when at least one is still FAILED."
          },
          "pdfStatus": {
            "additionalProperties": {
              "$ref": "#/components/schemas/RegeneratePdfDocStatus"
            },
            "type": "object",
            "title": "Pdfstatus",
            "description": "Full per-document status map after the merge"
          },
          "failedDocumentIds": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Faileddocumentids"
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "success",
          "chainId",
          "documentId",
          "chainStatus",
          "message"
        ],
        "title": "RegenerateChainPdfResponse",
        "description": "Response after a regenerate-pdf attempt.\n\nThe endpoint waits for the workflow to complete so the caller can show\nthe user the immediate outcome (success/failure) without polling."
      },
      "RegeneratePdfDocStatus": {
        "properties": {
          "status": {
            "type": "string",
            "title": "Status",
            "description": "SUCCESS | FAILED"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "attempts": {
            "type": "integer",
            "title": "Attempts"
          },
          "lastAttemptAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Lastattemptat"
          },
          "s3Key": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "S3Key"
          },
          "pdfHash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pdfhash"
          }
        },
        "type": "object",
        "required": [
          "status",
          "attempts"
        ],
        "title": "RegeneratePdfDocStatus",
        "description": "Per-document entry of chain.config.pdfStatus, exposed verbatim."
      },
      "ResendChainRequest": {
        "properties": {
          "roleName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Rolename",
            "description": "If set, only resend for this role"
          }
        },
        "type": "object",
        "title": "ResendChainRequest",
        "description": "POST /v2/chains/{id}/resend-invitations — re-send invites for an already-invited chain."
      },
      "RevocationSource": {
        "type": "string",
        "enum": [
          "crl",
          "ocsp",
          "colima",
          "trust_chain",
          "expired",
          "unknown"
        ],
        "title": "RevocationSource",
        "description": "Where the revocation info came from."
      },
      "RevocationStatus": {
        "type": "string",
        "enum": [
          "valid",
          "revoked",
          "unknown",
          "expired"
        ],
        "title": "RevocationStatus",
        "description": "Certificate revocation verdict."
      },
      "RevocationVerifyResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "status": {
            "$ref": "#/components/schemas/RevocationStatus"
          },
          "source": {
            "$ref": "#/components/schemas/RevocationSource"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "certificate": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/CertBasicInfo"
              },
              {
                "type": "null"
              }
            ]
          },
          "trustChain": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/TrustChainInfo"
              },
              {
                "type": "null"
              }
            ]
          },
          "crlUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Crlurl"
          },
          "cacheAgeMinutes": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cacheageminutes"
          },
          "crlTotalRevoked": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Crltotalrevoked"
          }
        },
        "type": "object",
        "required": [
          "status",
          "source",
          "message"
        ],
        "title": "RevocationVerifyResponse",
        "description": "Response for POST /verify-revocation — full multi-layer check."
      },
      "RoleCreate": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Role name: Cliente, Prestador, etc."
          },
          "color": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Color",
            "description": "Hex color for UI: #8b5cf6"
          },
          "contactEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactemail"
          },
          "contactPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactphone"
          },
          "contactName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactname"
          },
          "sortOrder": {
            "type": "integer",
            "title": "Sortorder",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "name"
        ],
        "title": "RoleCreate",
        "description": "Role definition when creating a chain."
      },
      "RoleResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "color": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Color"
          },
          "contactEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactemail"
          },
          "contactPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactphone"
          },
          "contactName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contactname"
          },
          "sortOrder": {
            "type": "integer",
            "title": "Sortorder"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "sortOrder"
        ],
        "title": "RoleResponse"
      },
      "RollbackRequest": {
        "properties": {
          "targetVersion": {
            "type": "integer",
            "minimum": 1.0,
            "title": "Targetversion",
            "description": "Version number to rollback to"
          }
        },
        "type": "object",
        "required": [
          "targetVersion"
        ],
        "title": "RollbackRequest",
        "description": "Request to rollback a template to a previous version."
      },
      "SSETokenResponse": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token",
            "description": "One-time SSE connection token (use within 60s)"
          },
          "expires_in": {
            "type": "integer",
            "title": "Expires In",
            "description": "Seconds until the token expires",
            "default": 60
          }
        },
        "type": "object",
        "required": [
          "token"
        ],
        "title": "SSETokenResponse"
      },
      "SecurityTestResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "description": "Always true if authenticated"
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "Success message"
          },
          "authenticatedUser": {
            "type": "string",
            "title": "Authenticateduser",
            "description": "Email of authenticated user"
          },
          "tenantId": {
            "type": "string",
            "title": "Tenantid",
            "description": "Tenant ID"
          },
          "scopes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Scopes",
            "description": "Granted scopes"
          },
          "environment": {
            "type": "string",
            "title": "Environment",
            "description": "Key environment"
          }
        },
        "type": "object",
        "required": [
          "success",
          "message",
          "authenticatedUser",
          "tenantId",
          "scopes",
          "environment"
        ],
        "title": "SecurityTestResponse",
        "description": "Response schema for security test endpoint."
      },
      "SendOtpRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token"
          },
          "email": {
            "type": "string",
            "format": "email",
            "title": "Email"
          }
        },
        "type": "object",
        "required": [
          "token",
          "email"
        ],
        "title": "SendOtpRequest"
      },
      "SignDocumentRequest": {
        "properties": {
          "documentId": {
            "type": "string",
            "title": "Documentid",
            "description": "UUID del documento a firmar"
          },
          "signatureId": {
            "type": "string",
            "title": "Signatureid",
            "description": "UUID de la firma del participante"
          },
          "cerBase64": {
            "type": "string",
            "title": "Cerbase64",
            "description": "Archivo .cer codificado en base64"
          },
          "keyBase64": {
            "type": "string",
            "title": "Keybase64",
            "description": "Archivo .key codificado en base64"
          },
          "password": {
            "type": "string",
            "title": "Password",
            "description": "Contraseña de la llave privada"
          }
        },
        "type": "object",
        "required": [
          "documentId",
          "signatureId",
          "cerBase64",
          "keyBase64",
          "password"
        ],
        "title": "SignDocumentRequest",
        "description": "Request to sign a document hash with SAT keys.\n\nThe .cer, .key and password are received in base64 so they can be\ntransmitted safely over JSON.  The backend decodes them, loads the\nSigner, signs the document hash, and stores the PKCS7 result."
      },
      "SignDocumentResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "signedHash": {
            "type": "string",
            "title": "Signedhash",
            "description": "Hash PKCS7 resultante"
          },
          "certificate": {
            "$ref": "#/components/schemas/CertificateInfoResponse"
          },
          "message": {
            "type": "string",
            "title": "Message",
            "default": "Documento firmado exitosamente con FEA SAT"
          },
          "revocationStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revocationstatus",
            "description": "Estado de revocación: valid, unknown"
          },
          "revocationSource": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Revocationsource",
            "description": "Fuente de verificación: crl, ocsp, colima"
          },
          "trustChainVerified": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Trustchainverified",
            "description": "Si la cadena de confianza del SAT fue verificada"
          }
        },
        "type": "object",
        "required": [
          "signedHash",
          "certificate"
        ],
        "title": "SignDocumentResponse",
        "description": "Response after successfully signing with SAT keys."
      },
      "SignatureFieldAnchor": {
        "properties": {
          "roleName": {
            "type": "string",
            "title": "Rolename"
          },
          "anchorString": {
            "type": "string",
            "title": "Anchorstring"
          },
          "height": {
            "type": "integer",
            "title": "Height",
            "default": 100
          },
          "includeInAllPages": {
            "type": "boolean",
            "title": "Includeinallpages",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "roleName",
          "anchorString"
        ],
        "title": "SignatureFieldAnchor",
        "description": "Anchor-based field placement: search text in PDF, place field there."
      },
      "SignatureFieldConfig": {
        "properties": {
          "mode": {
            "type": "string",
            "title": "Mode",
            "description": "anchor | auto | explicit",
            "default": "auto"
          },
          "position": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Position",
            "description": "For auto mode: last_page_bottom",
            "default": "last_page_bottom"
          },
          "fields": {
            "items": {
              "$ref": "#/components/schemas/SignatureFieldAnchor"
            },
            "type": "array",
            "title": "Fields",
            "description": "For anchor mode: list of anchor configs per role"
          },
          "placements": {
            "items": {
              "$ref": "#/components/schemas/ExplicitFieldPlacement"
            },
            "type": "array",
            "title": "Placements",
            "description": "For explicit mode: per-(template, role) field coordinates from the wizard editor"
          }
        },
        "type": "object",
        "title": "SignatureFieldConfig",
        "description": "How signature fields are placed on generated PDFs.\n\nmode=\"anchor\": search for text in the PDF and place fields at those positions.\nmode=\"auto\": place fields automatically at the bottom of the last page.\nmode=\"explicit\": use the per-(template, role) coordinates in `placements`."
      },
      "SignatureFieldCreate": {
        "properties": {
          "participantEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Participantemail",
            "description": "Email of the participant (optional if participantWhatsapp provided)"
          },
          "participantWhatsapp": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Participantwhatsapp",
            "description": "WhatsApp number of the participant (must start with +). Optional if participantEmail provided."
          },
          "pageNumber": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pagenumber",
            "description": "Page number (starting from 1, not 0)",
            "default": 1,
            "example": 1
          },
          "pageNumbers": {
            "anyOf": [
              {
                "items": {
                  "type": "integer"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pagenumbers",
            "description": "Specific page numbers (1-indexed) where the field should be placed. Conflicts with includeInAllPages."
          },
          "position": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FieldPosition"
              },
              {
                "type": "null"
              }
            ]
          },
          "anchorString": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Anchorstring",
            "description": "Text anchor to search for in the PDF to position the signature field"
          },
          "includeInAllPages": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Includeinallpages",
            "default": false
          },
          "excludeFromPages": {
            "anyOf": [
              {
                "items": {
                  "type": "integer"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Excludefrompages",
            "description": "List of page numbers to exclude (starting from 1, not 0)",
            "example": [
              1,
              2
            ]
          },
          "height": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Height",
            "description": "Height of the signature field in points. Width is automatically calculated using a 2:1 ratio.",
            "default": 100,
            "example": 100
          }
        },
        "type": "object",
        "title": "SignatureFieldCreate"
      },
      "SignatureFieldResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message"
          },
          "data": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Data"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "SignatureFieldResponse",
        "description": "Response model for signature field operations"
      },
      "SignerFillVariablesRequest": {
        "properties": {
          "variables": {
            "items": {
              "$ref": "#/components/schemas/FillVariableItem"
            },
            "type": "array",
            "title": "Variables"
          }
        },
        "type": "object",
        "required": [
          "variables"
        ],
        "title": "SignerFillVariablesRequest",
        "description": "POST /v2/chains/{id}/my-fill-variables — signer fills their own variables (role resolved server-side)."
      },
      "SignerInfo": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Signer user ID"
          },
          "email": {
            "type": "string",
            "title": "Email",
            "description": "Signer email"
          },
          "phone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Phone",
            "description": "Signer phone (WhatsApp)"
          }
        },
        "type": "object",
        "required": [
          "id",
          "email"
        ],
        "title": "SignerInfo",
        "description": "Signer basic information."
      },
      "SignerPhonesResponse": {
        "properties": {
          "phones": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Phones"
          }
        },
        "type": "object",
        "required": [
          "phones"
        ],
        "title": "SignerPhonesResponse"
      },
      "SignerSummary": {
        "properties": {
          "email": {
            "type": "string",
            "title": "Email"
          },
          "name": {
            "type": "string",
            "title": "Name"
          }
        },
        "type": "object",
        "required": [
          "email",
          "name"
        ],
        "title": "SignerSummary"
      },
      "SignersData": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Signature state ID"
          },
          "status": {
            "type": "string",
            "title": "Status",
            "description": "Overall signature status (TODOS_FIRMARON, RECOLECTANDO_FIRMANTES, etc.)"
          },
          "signatures": {
            "items": {
              "$ref": "#/components/schemas/app__schemas__document_v2__SignatureInfo"
            },
            "type": "array",
            "title": "Signatures",
            "description": "List of signatures"
          },
          "signatureValidations": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signaturevalidations",
            "description": "Validation flags for this document (autografa, FEA, nom151, firma_biometrica, eIDAS, etc.)"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status"
        ],
        "title": "SignersData",
        "description": "Signers data for a document (signature state + signatures)."
      },
      "SigningSessionCreate": {
        "properties": {
          "document_id": {
            "type": "string",
            "format": "uuid",
            "title": "Document Id",
            "description": "UUID of an existing document the signer is a participant of."
          },
          "signer_email": {
            "type": "string",
            "format": "email",
            "title": "Signer Email",
            "description": "Email of the participant who will sign via the iframe."
          },
          "success_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2083,
                "minLength": 1,
                "format": "uri"
              },
              {
                "type": "null"
              }
            ],
            "title": "Success Url",
            "description": "URL to redirect to when signing completes successfully."
          },
          "cancel_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 2083,
                "minLength": 1,
                "format": "uri"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cancel Url",
            "description": "URL to redirect to if the signer cancels."
          },
          "brand_profile_id": {
            "anyOf": [
              {
                "type": "string",
                "format": "uuid"
              },
              {
                "type": "null"
              }
            ],
            "title": "Brand Profile Id",
            "description": "Optional brand profile id (custom colors/logo). Fase 2."
          },
          "allowed_origins": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Allowed Origins",
            "description": "Origins allowed to embed this session's iframe. Used to set Content-Security-Policy frame-ancestors. Leave empty to allow all."
          },
          "test_mode": {
            "type": "boolean",
            "title": "Test Mode",
            "description": "When true, the session is watermarked and does not consume credits. Use with allsign_test_sk_* keys for development.",
            "default": false
          },
          "otp_mode": {
            "type": "string",
            "enum": [
              "none",
              "required",
              "integrator_verified"
            ],
            "title": "Otp Mode",
            "description": "Identity verification mode:\n- 'none' (default): The client_secret is the authentication. The integrator is responsible for authenticating the signer in their own application before requesting this session. No OTP challenge in the iframe.\n- 'required': NOT YET IMPLEMENTED (fase 2). AllSign will send an OTP to the signer and require them to enter it in the iframe.\n- 'integrator_verified': NOT YET IMPLEMENTED (fase 2). The integrator passes a signed attestation of their own MFA check.",
            "default": "none"
          }
        },
        "type": "object",
        "required": [
          "document_id",
          "signer_email"
        ],
        "title": "SigningSessionCreate",
        "description": "Body for creating an embedded signing session."
      },
      "SigningSessionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Session id prefixed with \"as_sess_\"."
          },
          "client_secret": {
            "type": "string",
            "title": "Client Secret",
            "description": "Short-lived secret for the frontend SDK to mount the iframe. Returned ONCE — never again. Pass it to AllSign.modal/inline on the frontend."
          },
          "status": {
            "type": "string",
            "title": "Status",
            "description": "Session lifecycle status."
          },
          "document": {
            "$ref": "#/components/schemas/DocumentSummary"
          },
          "signer": {
            "$ref": "#/components/schemas/SignerSummary"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "title": "Expires At",
            "description": "When the client_secret expires (15 minutes)."
          }
        },
        "type": "object",
        "required": [
          "id",
          "client_secret",
          "status",
          "document",
          "signer",
          "expires_at"
        ],
        "title": "SigningSessionResponse",
        "description": "Response body for POST /v2/signing-sessions."
      },
      "SimpleDocumentResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Document ID"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "pdfBinaryB64": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pdfbinaryb64"
          },
          "pdfHash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pdfhash"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Description"
          },
          "createdAt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Createdat"
          },
          "creditsConsumed": {
            "type": "integer",
            "title": "Creditsconsumed"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "createdAt",
          "creditsConsumed"
        ],
        "title": "SimpleDocumentResponse",
        "description": "Simplified document response."
      },
      "SortOrderEnum": {
        "type": "string",
        "enum": [
          "asc",
          "desc"
        ],
        "title": "SortOrderEnum",
        "description": "Sort order options."
      },
      "StartSigningResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "message": {
            "type": "string",
            "title": "Message"
          },
          "previousStatus": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Previousstatus"
          },
          "currentStatus": {
            "type": "string",
            "title": "Currentstatus"
          },
          "creditsConsumed": {
            "type": "integer",
            "title": "Creditsconsumed",
            "default": 0
          }
        },
        "type": "object",
        "required": [
          "success",
          "message",
          "currentStatus"
        ],
        "title": "StartSigningResponse"
      },
      "TeamListMeta": {
        "properties": {
          "total": {
            "type": "integer",
            "title": "Total",
            "description": "Total number of team members"
          }
        },
        "type": "object",
        "required": [
          "total"
        ],
        "title": "TeamListMeta"
      },
      "TeamListResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "data": {
            "items": {
              "$ref": "#/components/schemas/TeamMemberResponse"
            },
            "type": "array",
            "title": "Data"
          },
          "meta": {
            "$ref": "#/components/schemas/TeamListMeta"
          }
        },
        "type": "object",
        "required": [
          "data",
          "meta"
        ],
        "title": "TeamListResponse",
        "description": "Response for listing tenant team members."
      },
      "TeamMemberActivityResponse": {
        "properties": {
          "userId": {
            "type": "string",
            "title": "Userid"
          },
          "name": {
            "type": "string",
            "title": "Name"
          },
          "initials": {
            "type": "string",
            "title": "Initials"
          },
          "role": {
            "type": "string",
            "title": "Role"
          },
          "sent": {
            "type": "integer",
            "title": "Sent",
            "description": "Documents sent by this member"
          },
          "signed": {
            "type": "integer",
            "title": "Signed",
            "description": "Documents fully signed"
          },
          "rate": {
            "type": "number",
            "title": "Rate",
            "description": "Completion rate percentage"
          }
        },
        "type": "object",
        "required": [
          "userId",
          "name",
          "initials",
          "role",
          "sent",
          "signed",
          "rate"
        ],
        "title": "TeamMemberActivityResponse",
        "description": "Per-member sending and signing stats."
      },
      "TeamMemberResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "User ID (UUID)"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Display name"
          },
          "email": {
            "type": "string",
            "title": "Email",
            "description": "Email address"
          },
          "role": {
            "type": "string",
            "title": "Role",
            "description": "Tenant role (owner, admin, developer, member, viewer)"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "email",
          "role"
        ],
        "title": "TeamMemberResponse",
        "description": "A single tenant team member.",
        "example": {
          "email": "pedro@empresa.com",
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "Pedro García",
          "role": "admin"
        }
      },
      "TemplateDeleteUsage": {
        "properties": {
          "documents": {
            "type": "integer",
            "title": "Documents",
            "description": "Active documents referencing this template",
            "default": 0
          },
          "chains": {
            "type": "integer",
            "title": "Chains",
            "description": "Document chains referencing this template",
            "default": 0
          }
        },
        "type": "object",
        "title": "TemplateDeleteUsage",
        "description": "Usage breakdown returned when a template is in use and cannot be deleted."
      },
      "TemplateEditHistoryResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "prompt": {
            "type": "string",
            "title": "Prompt"
          },
          "editType": {
            "type": "string",
            "title": "Edittype"
          },
          "aiResponseSummary": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Airesponsesummary"
          },
          "changesCount": {
            "type": "integer",
            "title": "Changescount",
            "default": 0
          },
          "modelUsed": {
            "type": "string",
            "title": "Modelused"
          },
          "tokensInput": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tokensinput"
          },
          "tokensOutput": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tokensoutput"
          },
          "latencyMs": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Latencyms"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "versionBefore": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Versionbefore"
          },
          "versionAfter": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Versionafter"
          },
          "errorMessage": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Errormessage"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "prompt",
          "editType",
          "modelUsed",
          "status",
          "createdAt"
        ],
        "title": "TemplateEditHistoryResponse",
        "description": "Response for an AI edit history entry."
      },
      "TemplateVariableInfo": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Variable name as written in the DOCX (snake_case)"
          },
          "label": {
            "type": "string",
            "title": "Label",
            "description": "Human-readable label auto-generated from the variable name"
          },
          "type": {
            "$ref": "#/components/schemas/VariableType",
            "description": "Variable type for form rendering",
            "default": "text"
          },
          "required": {
            "type": "boolean",
            "title": "Required",
            "default": true
          },
          "defaultValue": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Defaultvalue"
          }
        },
        "type": "object",
        "required": [
          "name",
          "label"
        ],
        "title": "TemplateVariableInfo",
        "description": "Information about a single template variable."
      },
      "TemplateVersionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "versionNumber": {
            "type": "integer",
            "title": "Versionnumber"
          },
          "s3Key": {
            "type": "string",
            "title": "S3Key"
          },
          "createdBy": {
            "type": "string",
            "title": "Createdby",
            "description": "user, ai, or system"
          },
          "variablesCount": {
            "type": "integer",
            "title": "Variablescount",
            "default": 0
          },
          "contentHash": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Contenthash"
          },
          "editHistoryId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Edithistoryid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "versionNumber",
          "s3Key",
          "createdBy",
          "createdAt"
        ],
        "title": "TemplateVersionResponse",
        "description": "Response for a template version snapshot."
      },
      "TestDataSetCreateRequest": {
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 255,
            "minLength": 1,
            "title": "Name",
            "description": "Display name"
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Values",
            "description": "Variable name → value pairs"
          }
        },
        "type": "object",
        "required": [
          "name",
          "values"
        ],
        "title": "TestDataSetCreateRequest",
        "description": "Request to create a test data set."
      },
      "TestDataSetResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Test data set UUID"
          },
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Display name"
          },
          "values": {
            "additionalProperties": {
              "type": "string"
            },
            "type": "object",
            "title": "Values",
            "description": "Variable name → value pairs"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "title": "Createdat"
          }
        },
        "type": "object",
        "required": [
          "id",
          "name",
          "createdAt"
        ],
        "title": "TestDataSetResponse",
        "description": "Response for a single test data set."
      },
      "TrustChainInfo": {
        "properties": {
          "trusted": {
            "type": "boolean",
            "title": "Trusted",
            "description": "Whether the cert was signed by a known SAT CA"
          },
          "issuerCn": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Issuercn",
            "description": "CN of the issuing CA"
          },
          "message": {
            "type": "string",
            "title": "Message",
            "description": "Human-readable verification result"
          }
        },
        "type": "object",
        "required": [
          "trusted",
          "message"
        ],
        "title": "TrustChainInfo",
        "description": "Result of certificate trust chain validation against SAT CAs."
      },
      "UpdateSignatureFieldRequest": {
        "properties": {
          "fieldId": {
            "type": "string",
            "title": "Fieldid",
            "description": "ID of the signature field to update"
          },
          "signerEmail": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signeremail",
            "description": "Email of the signer (optional if signerPhone provided)"
          },
          "signerPhone": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signerphone",
            "description": "WhatsApp phone of the signer (must start with +). Optional if signerEmail provided."
          },
          "x": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "X",
            "description": "Updated X coordinate of the signature field"
          },
          "y": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Y",
            "description": "Updated Y coordinate of the signature field"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Width",
            "description": "Updated width of the signature field"
          },
          "height": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Height",
            "description": "Updated height of the signature field"
          },
          "pageNumber": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Pagenumber",
            "description": "Page number where the signature field is located"
          },
          "includeInAllPages": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Includeinallpages",
            "description": "Whether the signature field should be included in all pages"
          },
          "totalPages": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Totalpages",
            "description": "Total number of pages in the PDF (required when enabling includeInAllPages)"
          },
          "propagateToLinked": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Propagatetolinked",
            "description": "When true, propagate resize/move changes to all linked fields (parent + copies)",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "fieldId"
        ],
        "title": "UpdateSignatureFieldRequest",
        "description": "Request model for updating a signature field.\nAt least one of signerEmail or signerPhone must be provided."
      },
      "UserProfileV2Response": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "User ID"
          },
          "fullName": {
            "type": "string",
            "title": "Fullname",
            "description": "Display-ready full name"
          },
          "email": {
            "type": "string",
            "title": "Email",
            "description": "User email"
          },
          "tenantId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Tenantid",
            "description": "Tenant ID if available"
          },
          "orgId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Orgid",
            "description": "Organization ID if available"
          }
        },
        "type": "object",
        "required": [
          "id",
          "fullName",
          "email"
        ],
        "title": "UserProfileV2Response",
        "description": "Lightweight user profile for V2 public APIs.",
        "example": {
          "email": "ada@example.com",
          "fullName": "Ada Lovelace",
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "orgId": "7f89e0d1-2345-6789-abcd-ef0123456789",
          "tenantId": "1e2ec3d4-5b6a-7f89-0123-456789abcdef"
        }
      },
      "ValidateTokenRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token"
          },
          "device": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Device",
            "description": "Device type: desktop or mobile"
          }
        },
        "type": "object",
        "required": [
          "token"
        ],
        "title": "ValidateTokenRequest",
        "description": "Request to validate an onboarding token."
      },
      "ValidateTokenResponse": {
        "properties": {
          "valid": {
            "type": "boolean",
            "title": "Valid"
          },
          "sessionId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sessionid"
          },
          "status": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Status"
          },
          "config": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Config"
          },
          "targetName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Targetname"
          },
          "mobileUrl": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mobileurl",
            "description": "URL for QR code mobile handoff"
          },
          "completedCaptures": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completedcaptures",
            "description": "Capture types already accepted (e.g. ['id_front','id_back'])"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "valid"
        ],
        "title": "ValidateTokenResponse",
        "description": "Response for token validation."
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "VariableAssignment": {
        "properties": {
          "variableName": {
            "type": "string",
            "title": "Variablename"
          },
          "roleName": {
            "type": "string",
            "title": "Rolename",
            "description": "Must match a role in the chain"
          },
          "label": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Label"
          },
          "type": {
            "type": "string",
            "title": "Type",
            "default": "text"
          },
          "required": {
            "type": "boolean",
            "title": "Required",
            "default": true
          },
          "inputMode": {
            "$ref": "#/components/schemas/InputModeEnum",
            "default": "free"
          },
          "sourceHint": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sourcehint"
          },
          "captureAction": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Captureaction"
          }
        },
        "type": "object",
        "required": [
          "variableName",
          "roleName"
        ],
        "title": "VariableAssignment",
        "description": "Assigns a variable to a role with config."
      },
      "VariableConfigItem": {
        "properties": {
          "name": {
            "type": "string",
            "title": "Name",
            "description": "Variable name as written in the DOCX (snake_case)"
          },
          "label": {
            "type": "string",
            "title": "Label",
            "description": "Human-readable label"
          },
          "type": {
            "$ref": "#/components/schemas/VariableType",
            "description": "Field type for form rendering",
            "default": "text"
          },
          "required": {
            "type": "boolean",
            "title": "Required",
            "description": "Whether this variable is required",
            "default": true
          },
          "defaultValue": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Defaultvalue",
            "description": "Default value for the variable"
          },
          "options": {
            "anyOf": [
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Options",
            "description": "Options for 'select' type variables"
          },
          "role": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Role",
            "description": "Inferred signer role from variable name prefix/suffix (e.g. 'Arrendador', 'Cliente')"
          }
        },
        "type": "object",
        "required": [
          "name",
          "label"
        ],
        "title": "VariableConfigItem",
        "description": "Rich metadata for a single template variable."
      },
      "VariableType": {
        "type": "string",
        "enum": [
          "text",
          "date",
          "currency",
          "textarea",
          "select",
          "number"
        ],
        "title": "VariableType",
        "description": "Supported variable types for template fields."
      },
      "VariablesToFillResponse": {
        "properties": {
          "chainId": {
            "type": "string",
            "title": "Chainid"
          },
          "chainName": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Chainname"
          },
          "chainStatus": {
            "type": "string",
            "title": "Chainstatus"
          },
          "roles": {
            "items": {
              "additionalProperties": true,
              "type": "object"
            },
            "type": "array",
            "title": "Roles",
            "description": "Array of {roleId, roleName, roleColor, variables: VariableToFill[]}"
          }
        },
        "type": "object",
        "required": [
          "chainId",
          "chainStatus",
          "roles"
        ],
        "title": "VariablesToFillResponse",
        "description": "GET /v2/chains/{id}/variables-to-fill — variables grouped by role."
      },
      "VerifyCertificateResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "certificate": {
            "$ref": "#/components/schemas/CertificateInfoResponse"
          },
          "warnings": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Warnings",
            "description": "Advertencias (ej. próximo a expirar)"
          }
        },
        "type": "object",
        "required": [
          "certificate"
        ],
        "title": "VerifyCertificateResponse",
        "description": "Response for POST /verify-certificate."
      },
      "VerifyOtpRequest": {
        "properties": {
          "token": {
            "type": "string",
            "title": "Token"
          },
          "code": {
            "type": "string",
            "title": "Code"
          }
        },
        "type": "object",
        "required": [
          "token",
          "code"
        ],
        "title": "VerifyOtpRequest"
      },
      "VerifySessionResponse": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "mounted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Mounted At"
          },
          "completed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Completed At"
          },
          "test_mode": {
            "type": "boolean",
            "title": "Test Mode"
          },
          "signer": {
            "$ref": "#/components/schemas/SignerSummary"
          },
          "document": {
            "$ref": "#/components/schemas/DocumentSigningContext"
          },
          "signature": {
            "$ref": "#/components/schemas/app__api__v2__embedded__session_router__SignatureInfo"
          },
          "evidence": {
            "$ref": "#/components/schemas/EvidenceBundle"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "created_at",
          "mounted_at",
          "completed_at",
          "test_mode",
          "signer",
          "document",
          "signature",
          "evidence"
        ],
        "title": "VerifySessionResponse",
        "description": "Response body for POST /v2/signing-sessions/{id}/verify."
      },
      "VerifySignatureResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success",
            "default": true
          },
          "isValid": {
            "type": "boolean",
            "title": "Isvalid",
            "description": "¿La firma criptográfica es válida?"
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "isValid",
          "message"
        ],
        "title": "VerifySignatureResponse",
        "description": "Result of verifying a signed hash."
      },
      "VoidRequest": {
        "properties": {
          "reason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Reason",
            "description": "Reason for voiding"
          }
        },
        "type": "object",
        "title": "VoidRequest"
      },
      "VoidResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "success",
          "message"
        ],
        "title": "VoidResponse"
      },
      "WhatsAppSendOtpRequest": {
        "properties": {
          "phone": {
            "type": "string",
            "maxLength": 20,
            "minLength": 10,
            "title": "Phone",
            "description": "Phone number with country code (e.g. '+5215512345678' or '5215512345678')"
          },
          "language": {
            "type": "string",
            "title": "Language",
            "description": "Language for the WhatsApp message: 'es' or 'en'",
            "default": "es"
          },
          "code": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 8,
                "minLength": 4
              },
              {
                "type": "null"
              }
            ],
            "title": "Code",
            "description": "Optional OTP code to send (provided by Better Auth). If omitted, a new OTP is generated."
          }
        },
        "type": "object",
        "required": [
          "phone"
        ],
        "title": "WhatsAppSendOtpRequest",
        "description": "Request to send a login OTP via WhatsApp."
      },
      "WhatsAppSendOtpResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "expires_in_seconds": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Expires In Seconds"
          },
          "delivery_method": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Delivery Method"
          },
          "cooldown_remaining": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Cooldown Remaining"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "WhatsAppSendOtpResponse"
      },
      "WhatsAppVerifyRequest": {
        "properties": {
          "phone": {
            "type": "string",
            "maxLength": 20,
            "minLength": 10,
            "title": "Phone",
            "description": "Same phone number used in send-otp"
          },
          "code": {
            "type": "string",
            "maxLength": 6,
            "minLength": 6,
            "title": "Code",
            "description": "The 6-digit OTP code from WhatsApp"
          }
        },
        "type": "object",
        "required": [
          "phone",
          "code"
        ],
        "title": "WhatsAppVerifyRequest",
        "description": "Request to verify the login OTP."
      },
      "WhatsAppVerifyResponse": {
        "properties": {
          "success": {
            "type": "boolean",
            "title": "Success"
          },
          "user": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "User"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error"
          },
          "attempts_remaining": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Attempts Remaining"
          },
          "locked": {
            "anyOf": [
              {
                "type": "boolean"
              },
              {
                "type": "null"
              }
            ],
            "title": "Locked"
          }
        },
        "type": "object",
        "required": [
          "success"
        ],
        "title": "WhatsAppVerifyResponse"
      },
      "WorkflowStatusResponse": {
        "properties": {
          "status": {
            "type": "string",
            "title": "Status",
            "description": "processing | completed | failed"
          },
          "step": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Step",
            "description": "Current pipeline step"
          },
          "progress": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Progress",
            "description": "Progress 0-100"
          },
          "message": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Message",
            "description": "Human-readable status"
          },
          "documentId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Documentid"
          },
          "creditsConsumed": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Creditsconsumed"
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Error",
            "description": "Error message (if failed)"
          }
        },
        "type": "object",
        "required": [
          "status"
        ],
        "title": "WorkflowStatusResponse",
        "description": "Current status of a document creation workflow."
      },
      "app__api__v2__embedded__session_router__SignatureInfo": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "signed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Signed At"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "signed_at"
        ],
        "title": "SignatureInfo"
      },
      "app__schemas__document_v2__SignatureInfo": {
        "properties": {
          "id": {
            "type": "string",
            "title": "Id",
            "description": "Signature ID"
          },
          "status": {
            "type": "string",
            "title": "Status",
            "description": "Signature status (SENT, SIGNED, etc.)"
          },
          "signer": {
            "$ref": "#/components/schemas/SignerInfo",
            "description": "Signer information"
          }
        },
        "type": "object",
        "required": [
          "id",
          "status",
          "signer"
        ],
        "title": "SignatureInfo",
        "description": "Signature information for a document."
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key",
        "description": "Enter your AllSign API key (e.g., allsign_live_sk_xxx)"
      }
    }
  },
  "security": [
    {
      "HTTPBearer": []
    }
  ]
}