{
  "openapi": "3.0.3",
  "info": {
    "title": "SecureSignature Agent API",
    "version": "2.6.0",
    "description": "Account-scoped template and envelope API with SQL idempotency and conditional writes. Legacy routes retain their contract. HS256 account JWT requires account-id, api-key and exp. JSON limit 1 MiB; PDF upload JSON limit 12 MiB. PDF files are limited to 8 MiB decoded and 200 pages, with 20 files, 1000 pages and 32 MiB embedded base64 per authored aggregate. Coordinates are percentages with one-based pages. Recipient sessions are created only at send. With DurableJobs.Enabled, draft send persists its email intent in the same SQL transaction; delivery_status=queued confirms outbox acceptance, not provider/inbox delivery. Email/webhook and PDF jobs are dispatched independently of IIS with bounded retries and dead letters. External delivery is at-least-once; a crash after provider acceptance can duplicate delivery. An operation receipt is not a delivery-job status. PDF 202/Retry-After remains the polling contract; download_id is not an operation ID. Reconcile uncertain operation receipts before any new mutation key. API audit is persisted before business execution and before returning the final response; explicit ApiAuditEvent migration is required. HTTP 503 audit_outcome_unconfirmed requires reconciliation and must not be interpreted as rollback. Audit contains bounded metadata, not document/request bodies. Agent credentials use Bearer ssagent.<agentId N>.<credentialId N>.<random secret>, with server-managed scopes and expiry/revocation checked on every request. x-agent-scopes lists ALL required permissions, independent of legacy account JWT access. AgentId is stable across credential rotation; the operation namespace is account plus AgentId, not credential ID. Scope authorization runs before receipt replay. Credentials are provisioned by a privileged operator, not a public API. Revocation applies to subsequent authentication, not transactions already executing. Read-only delivery APIs require delivery.read for agents and enforce SQL account ownership. Only jobs with verified ownership metadata are visible; older unscoped jobs are not reconstructed from payloads. Completed fanout is not completed email delivery; provider acceptance is not inbox confirmation. Reading/polling never retries or enqueues jobs."
  },
  "servers": [
    {
      "url": "../",
      "description": "Relative to /openapi/v2.json: application root including its IIS virtual directory. For a generated client, set the Sandbox application base URL explicitly; never fall back to Production."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "agentBearer": []
    }
  ],
  "paths": {
    "/api/v2/accounts/{accountId}/templates": {
      "get": {
        "operationId": "listTemplates",
        "summary": "List account templates",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "pageNumber",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "numRecord",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplatePageResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "template.read"
        ]
      },
      "post": {
        "operationId": "createTemplate",
        "summary": "Create disabled template",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "accountId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateCreate"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      }
    },
    "/api/v2/templates/{templateId}/fields": {
      "get": {
        "operationId": "getTemplateFields",
        "summary": "Get template roles and fields",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateFieldsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "template.read"
        ]
      },
      "put": {
        "operationId": "replaceTemplateFields",
        "summary": "Replace full field layout",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateFieldsWrite"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      }
    },
    "/api/v2/templates/{templateId}/documents/{fileType}": {
      "post": {
        "operationId": "downloadTemplate",
        "summary": "Download combined template PDF",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "fileType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "pdf"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "template.read"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelopes": {
      "post": {
        "operationId": "createEnvelope",
        "summary": "Create envelope from account templates",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEnvelope"
              }
            }
          }
        },
        "description": "Returns a durable minimal receipt; recipient access codes, signing URLs and document content are not stored in the operation ledger. applied means the command returned success, not confirmed email delivery. Poll GET /api/v2/operations/{operationId}. Do not retry an uncertain operation with a new key. Legacy refile is multi-step, not atomic.",
        "x-agent-scopes": [
          "envelope.write",
          "envelope.send",
          "template.read"
        ]
      },
      "get": {
        "operationId": "listEnvelopes",
        "summary": "List Envelopes",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "integer",
              "enum": [
                0,
                10,
                100,
                11,
                12,
                14
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeListResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelopes/{envelopeID}": {
      "get": {
        "operationId": "getEnvelope",
        "summary": "Read envelope and current ETag",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "Strong envelope aggregate version; includes signer and session changes.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "envelope.read"
        ]
      },
      "delete": {
        "operationId": "deleteEnvelope",
        "summary": "Delete envelope",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "f",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "enum": [
                0,
                1
              ],
              "default": 0
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Returns a durable minimal receipt; recipient access codes, signing URLs and document content are not stored in the operation ledger. applied means the command returned success, not confirmed email delivery. Poll GET /api/v2/operations/{operationId}. Do not retry an uncertain operation with a new key. Legacy refile is multi-step, not atomic.",
        "x-agent-scopes": [
          "envelope.delete"
        ],
        "x-agent-conditional-scopes": {
          "envelope.send": "Required for f=1, which can send void notifications."
        }
      }
    },
    "/api/v2/accounts/{accountID}/envelopes/{envelopeID}/void": {
      "post": {
        "operationId": "voidEnvelope",
        "summary": "Void envelope",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "msg",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Returns a durable minimal receipt; recipient access codes, signing URLs and document content are not stored in the operation ledger. applied means the command returned success, not confirmed email delivery. Poll GET /api/v2/operations/{operationId}. Do not retry an uncertain operation with a new key. Legacy refile is multi-step, not atomic.",
        "x-agent-scopes": [
          "envelope.delete",
          "envelope.send"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/fields": {
      "patch": {
        "operationId": "correctEnvelopeFields",
        "summary": "Correct merge fields on unsigned envelope",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Correction"
              }
            }
          }
        },
        "description": "Returns a durable minimal receipt; recipient access codes, signing URLs and document content are not stored in the operation ledger. applied means the command returned success, not confirmed email delivery. Poll GET /api/v2/operations/{operationId}. Do not retry an uncertain operation with a new key. Legacy refile is multi-step, not atomic.",
        "x-agent-scopes": [
          "envelope.write"
        ]
      },
      "put": {
        "operationId": "setEnvelopeDraftFields",
        "summary": "Set Envelope Draft Fields",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateFieldsWrite"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelopes/{envelopeID}/resend": {
      "post": {
        "operationId": "resendEnvelope",
        "summary": "Resend recipient emails",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Resend"
              }
            }
          }
        },
        "description": "Returns a durable minimal receipt; recipient access codes, signing URLs and document content are not stored in the operation ledger. applied means the command returned success, not confirmed email delivery. Poll GET /api/v2/operations/{operationId}. Do not retry an uncertain operation with a new key. Legacy refile is multi-step, not atomic.",
        "x-agent-scopes": [
          "envelope.send"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelopes/{envelopeID_Old}/refile/{use_signature_for_missing_initials}": {
      "post": {
        "operationId": "refileEnvelope",
        "summary": "Create replacement and transfer existing signatures",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID_Old",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "use_signature_for_missing_initials",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "0",
                "1"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string",
                  "enum": [
                    "true"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateEnvelope"
              }
            }
          }
        },
        "description": "Returns a durable minimal receipt; recipient access codes, signing URLs and document content are not stored in the operation ledger. applied means the command returned success, not confirmed email delivery. Poll GET /api/v2/operations/{operationId}. Do not retry an uncertain operation with a new key. Legacy refile is multi-step, not atomic.",
        "x-agent-scopes": [
          "envelope.read",
          "envelope.write",
          "envelope.send",
          "template.read"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelopes/{envelopeID}/waiting": {
      "get": {
        "operationId": "getWaitingRecipients",
        "summary": "Get next waiting recipients",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WaitingResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelopes/{envelopeID}/downloads/{pdfType}": {
      "post": {
        "operationId": "downloadEnvelope",
        "summary": "Prepare/download envelope file",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "pdfType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "2",
                "3",
                "4"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "202": {
            "description": "Existing PDF worker is preparing the file. Retry this same download endpoint after Retry-After. download_id belongs to the legacy worker and is not an /operations ID.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreparingResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/downloads/full/{pdfType}": {
      "post": {
        "operationId": "downloadEnvelopeFull",
        "summary": "Prepare/download complete envelope file",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "pdfType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "2",
                "3",
                "4"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "202": {
            "description": "Existing PDF worker is preparing the file. Retry this same download endpoint after Retry-After. download_id belongs to the legacy worker and is not an /operations ID.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreparingResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/sessions/{sessionKey}/downloads/{pdfType}": {
      "post": {
        "operationId": "downloadSessionDocument",
        "summary": "Download within recipient session scope",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "sessionKey",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "pdfType",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "1",
                "2",
                "3",
                "4"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              },
              "application/zip": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "202": {
            "description": "Existing PDF worker is preparing the file. Retry this same download endpoint after Retry-After. download_id belongs to the legacy worker and is not an /operations ID.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              },
              "Retry-After": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PreparingResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/operations/{operationId}": {
      "get": {
        "operationId": "getOperation",
        "summary": "Read operation owned by the same account and API configuration",
        "tags": [
          "Operations"
        ],
        "parameters": [
          {
            "name": "operationId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OperationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "operations.read"
        ]
      }
    },
    "/api/v2/templates/{templateId}": {
      "get": {
        "operationId": "getTemplateDefinition",
        "summary": "Read complete template definition and ETag",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "Strong template aggregate version including stored signing/sender settings."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateDefinitionResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "template.read"
        ]
      },
      "patch": {
        "operationId": "updateTemplateMetadata",
        "summary": "Update metadata or enabled state",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplatePatch"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      },
      "delete": {
        "operationId": "deleteTemplate",
        "summary": "Delete account-owned template",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.delete"
        ]
      }
    },
    "/api/v2/templates/{templateId}/clone": {
      "post": {
        "operationId": "cloneTemplate",
        "summary": "Clone with independent file/role/field IDs",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "201": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateCreate"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.read",
          "template.write"
        ]
      }
    },
    "/api/v2/templates/{templateId}/validation": {
      "get": {
        "operationId": "validateTemplate",
        "summary": "Check readiness before enabling",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "Strong template aggregate version including stored signing/sender settings."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateValidationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "template.read"
        ]
      }
    },
    "/api/v2/templates/{templateId}/files": {
      "post": {
        "operationId": "addTemplateFile",
        "summary": "Upload embedded PDF to template",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "201": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpload"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      }
    },
    "/api/v2/templates/{templateId}/files/{fileId}": {
      "get": {
        "operationId": "downloadTemplateFile",
        "summary": "Download a file belonging to this template",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "Strong template aggregate version including stored signing/sender settings."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "template.read"
        ]
      },
      "delete": {
        "operationId": "deleteTemplateFile",
        "summary": "Remove file after removing its field references",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.delete"
        ]
      }
    },
    "/api/v2/templates/{templateId}/files/order": {
      "put": {
        "operationId": "reorderTemplateFiles",
        "summary": "Replace complete file ordering",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateFileOrder"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      }
    },
    "/api/v2/templates/{templateId}/roles": {
      "put": {
        "operationId": "replaceTemplateRoles",
        "summary": "Replace recipient roles",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateRolesWrite"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      }
    },
    "/api/v2/templates/{templateId}/settings": {
      "put": {
        "operationId": "updateTemplateSettings",
        "summary": "Update envelope, signature and sender settings",
        "tags": [
          "Templates"
        ],
        "parameters": [
          {
            "name": "templateId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateSettingsWrite"
              }
            }
          }
        },
        "description": "Account JWT or scoped agent credential required. Mutations use durable idempotency; preserve key/body/If-Match when retrying. Read GET template for the next ETag and generated role/field IDs. Legacy procedures use the account's unique active owner for audit attribution; missing/ambiguous owner returns 409. Mutations do not send email, share across accounts or deploy anything.",
        "x-agent-scopes": [
          "template.write"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/envelope-drafts": {
      "post": {
        "operationId": "createEnvelopeDraft",
        "summary": "Create Envelope Draft",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvelopeDraftCreate"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ],
        "x-agent-conditional-scopes": {
          "template.read": "Required when importing template_ids."
        }
      }
    },
    "/api/v2/envelopes/{envelopeID}/definition": {
      "get": {
        "operationId": "envelopeDefinition",
        "summary": "Envelope Definition",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "Strong persisted envelope/recipient/session/signing/sender aggregate version."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDefinitionResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/draft": {
      "patch": {
        "operationId": "updateEnvelopeDraft",
        "summary": "Update Envelope Draft",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvelopeDraftMetadata"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/clone": {
      "post": {
        "operationId": "cloneEnvelopeDraft",
        "summary": "Clone Envelope Draft",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvelopeDraftMetadata"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.read",
          "envelope.write"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/files": {
      "post": {
        "operationId": "addEnvelopeDraftFile",
        "summary": "Add Envelope Draft File",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "201": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateUpload"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/files/{fileId}": {
      "get": {
        "operationId": "downloadEnvelopeFile",
        "summary": "Download Envelope File",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "Strong persisted envelope/recipient/session/signing/sender aggregate version."
              }
            },
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "x-agent-scopes": [
          "envelope.read"
        ]
      },
      "delete": {
        "operationId": "deleteEnvelopeDraftFile",
        "summary": "Delete Envelope Draft File",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "x-agent-scopes": [
          "envelope.delete"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/files/order": {
      "put": {
        "operationId": "orderEnvelopeDraftFiles",
        "summary": "Order Envelope Draft Files",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TemplateFileOrder"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/recipients": {
      "put": {
        "operationId": "setEnvelopeDraftRecipients",
        "summary": "Set Envelope Draft Recipients",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvelopeDraftRecipients"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/settings": {
      "put": {
        "operationId": "setEnvelopeDraftSettings",
        "summary": "Set Envelope Draft Settings",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvelopeDraftSettings"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.write"
        ],
        "x-agent-conditional-scopes": {
          "template.read": "Required for signing_template_id or sender_template_id."
        }
      }
    },
    "/api/v2/envelopes/{envelopeID}/validation": {
      "get": {
        "operationId": "validateEnvelopeDraft",
        "summary": "Validate Envelope Draft",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "schema": {
                  "type": "string"
                },
                "description": "Strong persisted envelope/recipient/session/signing/sender aggregate version."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TemplateValidationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/send": {
      "post": {
        "operationId": "sendEnvelopeDraft",
        "summary": "Send Envelope Draft",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/IfMatch"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              },
              "Operation-Id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                }
              },
              "Idempotency-Replayed": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeDraftMutationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          },
          "412": {
            "$ref": "#/components/responses/Error412"
          },
          "428": {
            "$ref": "#/components/responses/Error428"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EnvelopeSend"
              }
            }
          }
        },
        "x-agent-scopes": [
          "envelope.send"
        ]
      }
    },
    "/api/v2/envelopes/{envelopeID}/activity": {
      "get": {
        "operationId": "envelopeActivity",
        "summary": "Envelope Activity",
        "tags": [
          "Envelopes"
        ],
        "parameters": [
          {
            "name": "envelopeID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-Request-Id": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvelopeActivityResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "description": "Account JWT or scoped agent credential. Draft editing requires status 0 and no signing sessions. Mutations require durable idempotency and (except create) If-Match. Read definition for the new ETag. Send transitions once; delivery runs after commit and may return delivery_warning. Never retry an uncertain operation with a new key.",
        "x-agent-scopes": [
          "envelope.read"
        ]
      }
    },
    "/api/v2/accounts/{accountID}/deliveries": {
      "get": {
        "operationId": "listDeliveries",
        "summary": "List account delivery jobs",
        "tags": [
          "Deliveries"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "envelope_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "email",
                "webhook",
                "pdf"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "running",
                "completed",
                "dead"
              ]
            }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100000,
              "default": 1
            }
          },
          {
            "name": "page_size",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryPageResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "delivery.read"
        ],
        "description": "Account JWT or scoped agent credential. Read-only, account-bound job metadata; no payload, address, URL, document, lease token or retry command. Unscoped historical jobs and other-account IDs return no data (detail 404). Jobs remain traceable after envelope deletion. envelope_mail completed means fanout ended; graph/smtp completed means provider accepted, not inbox; webhook completed means receiver 2xx; pdf completed records generated output, use existing downloads for files. Lists are live views; page/total can change during dispatch."
      }
    },
    "/api/v2/accounts/{accountID}/deliveries/{deliveryId}": {
      "get": {
        "operationId": "getDelivery",
        "summary": "Get one account delivery job",
        "tags": [
          "Deliveries"
        ],
        "parameters": [
          {
            "name": "accountID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "deliveryId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-Request-Id": {
                "description": "Server-generated correlation identifier.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeliveryResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error400"
          },
          "401": {
            "$ref": "#/components/responses/Error401"
          },
          "403": {
            "$ref": "#/components/responses/Error403"
          },
          "404": {
            "$ref": "#/components/responses/Error404"
          },
          "405": {
            "$ref": "#/components/responses/Error405"
          },
          "409": {
            "$ref": "#/components/responses/Error409"
          },
          "413": {
            "$ref": "#/components/responses/Error413"
          },
          "415": {
            "$ref": "#/components/responses/Error415"
          },
          "422": {
            "$ref": "#/components/responses/Error422"
          },
          "500": {
            "$ref": "#/components/responses/Error500"
          },
          "503": {
            "$ref": "#/components/responses/Error503"
          }
        },
        "x-agent-scopes": [
          "delivery.read"
        ],
        "description": "Account JWT or scoped agent credential. Read-only, account-bound job metadata; no payload, address, URL, document, lease token or retry command. Unscoped historical jobs and other-account IDs return no data (detail 404). Jobs remain traceable after envelope deletion. envelope_mail completed means fanout ended; graph/smtp completed means provider accepted, not inbox; webhook completed means receiver 2xx; pdf completed records generated output, use existing downloads for files. Lists are live views; page/total can change during dispatch."
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "agentBearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "ssagent.<agentId N>.<credentialId N>.<secret>",
        "description": "Opaque 256-bit random secret; SQL stores only SHA-256. Pin AgentId in the agent journal/client. Scope assignments are server-side. No client-supplied scope claims."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": true,
        "description": "Unique per account and API configuration. 1–128 visible ASCII characters, no comma. Reuse exactly the same key and effective request after a network failure. Keys and uncertain operations do not expire automatically.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128,
          "pattern": "^[!-+\\--~]+$"
        }
      },
      "IfMatch": {
        "name": "If-Match",
        "in": "header",
        "required": true,
        "description": "Single strong ETag from GET envelope or GET template. Wildcards, weak tags and lists are rejected. Re-read and use a new key after a 412.",
        "schema": {
          "type": "string",
          "pattern": "^\"[0-9a-f]{64}\"$"
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "additionalProperties": false,
            "required": [
              "code",
              "message"
            ]
          },
          "requestId": {
            "type": "string"
          },
          "operationId": {
            "type": "string",
            "format": "uuid"
          },
          "resourceId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "required": [
          "error",
          "requestId"
        ]
      },
      "FieldValue": {
        "type": "object",
        "properties": {
          "field_id": {
            "type": "string",
            "minLength": 1
          },
          "field_value": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "field_id"
        ]
      },
      "MergeSigner": {
        "type": "object",
        "properties": {
          "signer_id": {
            "type": "string",
            "nullable": true
          },
          "role_name": {
            "type": "string",
            "minLength": 1
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FieldValue"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "role_name"
        ]
      },
      "TemplateInput": {
        "type": "object",
        "properties": {
          "template_id": {
            "type": "string",
            "minLength": 1,
            "description": "Account-owned template business code (not document_template_id UUID)."
          },
          "merge_field_signers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MergeSigner"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "template_id"
        ]
      },
      "EnvelopeOptions": {
        "type": "object",
        "properties": {
          "envelope_expires": {
            "type": "integer",
            "nullable": true
          },
          "send_warning_before_expiring": {
            "type": "integer",
            "nullable": true
          },
          "send_first_reminder": {
            "type": "integer",
            "nullable": true
          },
          "repeatedly_send_interval": {
            "type": "integer",
            "nullable": true
          },
          "reminders_days": {
            "type": "integer",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "RecipientInput": {
        "type": "object",
        "properties": {
          "document_template_id": {
            "type": "string",
            "nullable": true
          },
          "signer_id": {
            "type": "string",
            "nullable": true
          },
          "role_name": {
            "type": "string",
            "nullable": true
          },
          "full_name": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "roleName": {
            "type": "string",
            "nullable": true
          },
          "priority": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "type": "string",
            "enum": [
              "0",
              "1",
              "2"
            ],
            "description": "0 signer; 1 viewer; 2 copy recipient."
          },
          "send_complete_email": {
            "type": "boolean",
            "nullable": true
          },
          "required_access_code": {
            "type": "boolean"
          },
          "unlock_to_open": {
            "type": "object",
            "properties": {
              "access_code": {
                "type": "string",
                "nullable": true
              }
            },
            "additionalProperties": false
          }
        },
        "additionalProperties": false
      },
      "SigningInput": {
        "type": "object",
        "properties": {
          "signing_order": {
            "type": "boolean",
            "nullable": true
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RecipientInput"
            }
          }
        },
        "additionalProperties": false
      },
      "CreateEnvelope": {
        "type": "object",
        "properties": {
          "email_subject": {
            "type": "string",
            "nullable": true
          },
          "email_message": {
            "type": "string",
            "nullable": true
          },
          "envelope_options": {
            "$ref": "#/components/schemas/EnvelopeOptions"
          },
          "send_email": {
            "type": "boolean"
          },
          "templates": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/TemplateInput"
            }
          },
          "signing": {
            "$ref": "#/components/schemas/SigningInput"
          },
          "selected_signing_settings_template_id": {
            "type": "string",
            "nullable": true
          },
          "selected_sender_info_template_id": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "templates"
        ]
      },
      "Correction": {
        "type": "object",
        "properties": {
          "templates": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "template_id": {
                  "type": "string",
                  "minLength": 1
                },
                "merge_field_signers": {
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "$ref": "#/components/schemas/MergeSigner"
                  }
                }
              },
              "additionalProperties": false,
              "required": [
                "template_id",
                "merge_field_signers"
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "templates"
        ]
      },
      "Resend": {
        "type": "object",
        "properties": {
          "recipients": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "properties": {
                "role_name": {
                  "type": "string",
                  "minLength": 1
                },
                "force_send_if_finish": {
                  "type": "boolean"
                }
              },
              "additionalProperties": false,
              "required": [
                "role_name"
              ]
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "recipients"
        ]
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "applied": {
            "type": "boolean"
          },
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "email_sending": {
            "type": "boolean"
          },
          "delivery_warning": {
            "type": "boolean"
          },
          "delivery_status": {
            "type": "string",
            "enum": [
              "reported",
              "not_confirmed",
              "queued",
              "not_requested",
              "submitted"
            ]
          },
          "sent_count": {
            "type": "integer"
          },
          "unsent_count": {
            "type": "integer"
          }
        },
        "additionalProperties": false,
        "required": [
          "applied"
        ]
      },
      "Template": {
        "type": "object",
        "properties": {
          "document_template_id": {
            "type": "string",
            "format": "uuid"
          },
          "template_id": {
            "type": "string"
          },
          "template_name": {
            "type": "string"
          },
          "roles": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "additionalProperties": false,
        "required": [
          "document_template_id",
          "template_id",
          "template_name",
          "roles"
        ]
      },
      "TemplatePage": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Template"
            }
          },
          "total": {
            "type": "integer"
          },
          "page": {
            "type": "integer"
          },
          "page_size": {
            "type": "integer"
          }
        },
        "additionalProperties": false,
        "required": [
          "items",
          "total",
          "page",
          "page_size"
        ]
      },
      "TemplateRole": {
        "type": "object",
        "properties": {
          "role_name": {
            "type": "string"
          },
          "role_type": {
            "type": "string"
          },
          "fields": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "document_fields_id": {
                  "type": "string"
                },
                "fieldtype": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "id",
                "document_fields_id",
                "fieldtype"
              ]
            }
          },
          "id": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "role_name",
          "role_type",
          "fields",
          "id"
        ]
      },
      "Recipient": {
        "type": "object",
        "properties": {
          "session_id": {
            "type": "string",
            "nullable": true
          },
          "role_name": {
            "type": "string",
            "nullable": true
          },
          "role_type": {
            "type": "string"
          },
          "signer_name": {
            "type": "string",
            "nullable": true
          },
          "signer_email": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string"
          },
          "completed_date": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "Envelope": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "integer"
          },
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "envelope_name": {
            "type": "string",
            "nullable": true
          },
          "sent_date": {
            "type": "string",
            "format": "date-time"
          },
          "expires_on": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "type": "string"
          },
          "signing_order": {
            "type": "boolean"
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Recipient"
            },
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "account_id",
          "envelope_id",
          "status"
        ]
      },
      "Waiting": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "account_id",
          "envelope_id",
          "envelope_subject",
          "envelope_signing_order",
          "waiting_for_completion"
        ],
        "properties": {
          "account_id": {
            "type": "string"
          },
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "envelope_subject": {
            "type": "string",
            "nullable": true
          },
          "envelope_signing_order": {
            "type": "string",
            "enum": [
              "true",
              "false"
            ]
          },
          "waiting_for_completion": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "name": {
                  "type": "string",
                  "nullable": true
                },
                "role": {
                  "type": "string",
                  "nullable": true
                },
                "role_description": {
                  "type": "string",
                  "nullable": true
                },
                "email": {
                  "type": "string",
                  "nullable": true
                },
                "session_id": {
                  "type": "string",
                  "nullable": true
                },
                "url": {
                  "type": "string",
                  "nullable": true
                }
              }
            }
          }
        }
      },
      "Preparing": {
        "type": "object",
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "preparing"
            ]
          },
          "download_id": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "state",
          "download_id"
        ]
      },
      "Operation": {
        "type": "object",
        "properties": {
          "operationId": {
            "type": "string",
            "format": "uuid"
          },
          "state": {
            "type": "string",
            "enum": [
              "in_progress",
              "completed",
              "failed",
              "indeterminate"
            ]
          },
          "httpStatus": {
            "type": "integer",
            "nullable": true
          },
          "result": {
            "type": "object",
            "nullable": true,
            "additionalProperties": true
          },
          "resourceId": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "required": [
          "operationId",
          "state",
          "httpStatus",
          "result",
          "resourceId"
        ]
      },
      "TemplatePageResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/TemplatePage"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ]
      },
      "EnvelopeResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Envelope"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ]
      },
      "WaitingResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Waiting"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ]
      },
      "PreparingResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Preparing"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ]
      },
      "OperationResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Operation"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ]
      },
      "TemplateFieldsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateRole"
            }
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ]
      },
      "MutationResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Receipt"
          },
          "requestId": {
            "type": "string"
          },
          "operationId": {
            "type": "string",
            "format": "uuid"
          },
          "resourceId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "additionalProperties": false,
        "required": [
          "data",
          "requestId",
          "operationId"
        ]
      },
      "TemplateCreate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "template_code": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,49}$"
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "enabled": {
            "type": "boolean",
            "enum": [
              false
            ],
            "default": false
          }
        },
        "required": [
          "template_code",
          "name"
        ],
        "description": "Create and clone start disabled. Choose a new account-unique business template_code."
      },
      "TemplatePatch": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "template_code": {
            "type": "string",
            "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,49}$"
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1
          },
          "description": {
            "type": "string",
            "maxLength": 500
          },
          "enabled": {
            "type": "boolean"
          }
        },
        "minProperties": 1,
        "description": "Partial metadata update. Enabling requires a complete, valid document. Null leaves a property unchanged; at least one non-null property is required."
      },
      "TemplateUpload": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200,
            "minLength": 1,
            "description": "PDF basename only; no path separators/control characters."
          },
          "content_base64": {
            "type": "string",
            "format": "byte",
            "description": "PDF bytes encoded as base64; decoded maximum 8 MiB, 1–200 pages, no encryption. JSON body maximum 12 MiB."
          }
        },
        "required": [
          "name",
          "content_base64"
        ]
      },
      "TemplateFileOrder": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "maxItems": 20,
            "uniqueItems": true
          }
        },
        "required": [
          "file_ids"
        ],
        "description": "Complete permutation of this template's file IDs; no omissions or duplicates."
      },
      "TemplateRoleInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1
          },
          "type": {
            "type": "string",
            "enum": [
              "signer",
              "viewer",
              "copy"
            ]
          },
          "priority": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "recipient_name": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "recipient_email": {
            "type": "string",
            "format": "email",
            "nullable": true
          },
          "send_complete_email": {
            "type": "boolean"
          },
          "required_access_code": {
            "type": "boolean"
          },
          "access_code": {
            "type": "string",
            "maxLength": 100,
            "nullable": true,
            "writeOnly": true
          }
        },
        "required": [
          "name",
          "type",
          "priority"
        ]
      },
      "TemplateRolesWrite": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "signing_order": {
            "type": "boolean",
            "default": false
          },
          "roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateRoleInput"
            },
            "maxItems": 100
          }
        },
        "required": [
          "roles"
        ],
        "description": "Replaces all roles. Omit id to create a role; existing id must belong to this template. A role referenced by a field cannot be removed or changed to viewer/copy. Null access_code preserves an existing code when required_access_code is true; false clears it. Role names must be unique ignoring case."
      },
      "TemplateFieldInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "key": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1
          },
          "file_id": {
            "type": "string",
            "format": "uuid"
          },
          "role_id": {
            "type": "string",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "enum": [
              "name",
              "email",
              "phone",
              "text",
              "multiple-line-text",
              "datesigned",
              "checkbox",
              "checkboxlist",
              "radiolist",
              "dropdownlist",
              "signature",
              "initial",
              "attachment"
            ]
          },
          "page": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200,
            "description": "One-based page number within the selected file."
          },
          "left": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 100,
            "default": 0
          },
          "top": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 100,
            "default": 0
          },
          "width": {
            "type": "number",
            "format": "float",
            "minimum": 0.01,
            "maximum": 100
          },
          "height": {
            "type": "number",
            "format": "float",
            "minimum": 0.01,
            "maximum": 100
          },
          "required": {
            "type": "boolean"
          },
          "read_only": {
            "type": "boolean"
          },
          "default_value": {
            "type": "string",
            "maxLength": 4000,
            "nullable": true
          },
          "label": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "tooltip": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "font_size": {
            "type": "integer",
            "nullable": true,
            "minimum": 6,
            "maximum": 72,
            "default": 10
          },
          "font": {
            "type": "string",
            "maxLength": 100,
            "nullable": true,
            "default": "Times New Roman"
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "nullable": true
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 200,
              "minLength": 1
            },
            "maxItems": 100,
            "nullable": true
          },
          "properties": {
            "$ref": "#/components/schemas/TemplateFieldProperties"
          }
        },
        "required": [
          "key",
          "file_id",
          "role_id",
          "type",
          "page",
          "width",
          "height"
        ],
        "description": "For a checkbox, default_value is checked or unchecked. Existing advanced properties are retained if properties is omitted."
      },
      "TemplateFieldsWrite": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateFieldInput"
            },
            "maxItems": 1000
          }
        },
        "required": [
          "fields"
        ],
        "description": "Replaces all fields. Omit id to create a field; retained IDs must already belong to this template. Coordinates are percentages, width/height positive, left+width and top+height <=100. Role must be a signer, file/page must exist, keys and IDs unique. List types require 1–100 distinct options; other types reject options. Signature/initial/attachment/datesigned reject non-empty defaults. Removing required signature fields from an enabled template is rejected."
      },
      "TemplateSigningStyle": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "tab_name": {
            "type": "string",
            "enum": [
              "draw",
              "upload",
              "preset"
            ]
          },
          "priority": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3
          },
          "hidden": {
            "type": "boolean"
          },
          "selected": {
            "type": "boolean"
          },
          "one_touch": {
            "type": "boolean"
          },
          "lock_signing_name": {
            "type": "boolean"
          },
          "default_color": {
            "type": "boolean"
          },
          "background_color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "nullable": true
          },
          "text_color": {
            "type": "string",
            "pattern": "^#[0-9a-fA-F]{6}$",
            "nullable": true
          }
        },
        "required": [
          "tab_name",
          "priority"
        ]
      },
      "TemplateSender": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "inherited": {
            "type": "boolean"
          },
          "first_name": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "last_name": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "company": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "address": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "address_2": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "city": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "state": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "zipcode": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "country_code": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "website": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "phone": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "timezone": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "timezone_name": {
            "type": "string",
            "maxLength": 100,
            "nullable": true
          },
          "email": {
            "type": "string",
            "format": "email",
            "nullable": true
          }
        },
        "required": [
          "inherited"
        ],
        "description": "inherited=true restores account sender settings; otherwise a valid email is required. URLs are stored as text and never fetched."
      },
      "TemplateSettingsWrite": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "email_subject": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "email_message": {
            "type": "string",
            "maxLength": 1000,
            "nullable": true
          },
          "expiration": {
            "type": "integer",
            "nullable": true,
            "enum": [
              0,
              1,
              null
            ]
          },
          "expires_after_days": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "maximum": 3650
          },
          "warning_before_days": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "maximum": 3650
          },
          "reminders_days": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "maximum": 3650
          },
          "first_reminder_after_days": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "maximum": 3650
          },
          "reminder_interval_days": {
            "type": "integer",
            "nullable": true,
            "minimum": 0,
            "maximum": 3650
          },
          "signing_styles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateSigningStyle"
            },
            "maxItems": 3,
            "nullable": true
          },
          "sender": {
            "$ref": "#/components/schemas/TemplateSender"
          }
        },
        "minProperties": 1,
        "description": "Partial update committed atomically. Missing/null section is unchanged; signing_styles=[] restores inheritance. Non-empty styles require unique names and exactly one visible selected style. No email is sent. Style names and priorities must be unique, selected style must be visible."
      },
      "TemplateRoleDefinition": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "signer",
              "viewer",
              "copy"
            ]
          },
          "priority": {
            "type": "integer"
          },
          "recipient_name": {
            "type": "string",
            "nullable": true
          },
          "recipient_email": {
            "type": "string",
            "nullable": true
          },
          "send_complete_email": {
            "type": "boolean"
          },
          "required_access_code": {
            "type": "boolean"
          },
          "has_access_code": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "type",
          "priority",
          "id",
          "has_access_code"
        ]
      },
      "TemplateFieldDefinition": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "key": {
            "type": "string",
            "nullable": true
          },
          "file_id": {
            "type": "string",
            "nullable": true
          },
          "role_id": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string"
          },
          "page": {
            "type": "integer"
          },
          "left": {
            "type": "number",
            "nullable": true
          },
          "top": {
            "type": "number",
            "nullable": true
          },
          "width": {
            "type": "number",
            "nullable": true
          },
          "height": {
            "type": "number",
            "nullable": true
          },
          "required": {
            "type": "boolean"
          },
          "read_only": {
            "type": "boolean"
          },
          "default_value": {
            "type": "string",
            "nullable": true
          },
          "label": {
            "type": "string",
            "nullable": true
          },
          "tooltip": {
            "type": "string",
            "nullable": true
          },
          "font_size": {
            "type": "integer"
          },
          "font": {
            "type": "string",
            "nullable": true
          },
          "color": {
            "type": "string",
            "nullable": true
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 200,
              "minLength": 1
            },
            "maxItems": 100,
            "nullable": true
          },
          "id": {
            "type": "string",
            "nullable": true
          },
          "properties": {
            "$ref": "#/components/schemas/TemplateFieldProperties"
          }
        },
        "required": [
          "key",
          "file_id",
          "role_id",
          "type",
          "page",
          "width",
          "height"
        ]
      },
      "TemplateFileDefinition": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "pages": {
            "type": "integer"
          },
          "priority": {
            "type": "integer"
          },
          "page_sizes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "width": {
                  "type": "number"
                },
                "height": {
                  "type": "number"
                }
              },
              "required": [
                "width",
                "height"
              ]
            }
          }
        },
        "required": [
          "id",
          "name",
          "pages",
          "priority",
          "page_sizes"
        ]
      },
      "TemplateDefinition": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "document_template_id": {
            "type": "string",
            "format": "uuid"
          },
          "template_code": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "maxLength": 200,
            "nullable": true
          },
          "description": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "enabled": {
            "type": "boolean"
          },
          "signing_order": {
            "type": "boolean"
          },
          "settings": {
            "$ref": "#/components/schemas/TemplateSettingsWrite"
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateFileDefinition"
            }
          },
          "roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateRoleDefinition"
            }
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateFieldDefinition"
            }
          }
        },
        "required": [
          "document_template_id",
          "template_code",
          "name",
          "description",
          "enabled",
          "signing_order",
          "settings",
          "files",
          "roles",
          "fields"
        ]
      },
      "TemplateDefinitionResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/TemplateDefinition"
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "data",
          "requestId"
        ]
      },
      "TemplateValidationResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "valid": {
                "type": "boolean"
              },
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "code"
                  ]
                }
              }
            },
            "required": [
              "valid",
              "issues"
            ]
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "data",
          "requestId"
        ]
      },
      "TemplateMutationResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "applied": {
                "type": "boolean"
              },
              "document_template_id": {
                "type": "string",
                "format": "uuid"
              },
              "file_id": {
                "type": "string",
                "format": "uuid"
              }
            },
            "required": [
              "applied",
              "document_template_id"
            ]
          },
          "requestId": {
            "type": "string"
          },
          "operationId": {
            "type": "string",
            "format": "uuid"
          },
          "resourceId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "data",
          "requestId",
          "operationId"
        ]
      },
      "TemplateFieldProperties": {
        "type": "object",
        "nullable": true,
        "additionalProperties": false,
        "properties": {
          "name_format": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "display_format": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "placeholder": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "option_label": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "option_value": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "font_style": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "font_weight": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "text_decoration": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_expression": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_type": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_value": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_from": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_to": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_one": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "validation_two": {
            "type": "string",
            "maxLength": 500,
            "nullable": true
          },
          "font_size_percent": {
            "type": "number",
            "minimum": 0,
            "maximum": 100,
            "nullable": true
          },
          "maximum_file_size": {
            "type": "integer",
            "format": "int64",
            "minimum": 0,
            "maximum": 104857600,
            "nullable": true
          },
          "show_full_text": {
            "type": "boolean",
            "nullable": true
          }
        },
        "description": "Optional existing-editor properties. Missing/null members preserve existing settings for a retained field ID. Empty strings clear text settings. Units and validation names follow the existing editor."
      },
      "EnvelopeDraftCreate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "template_ids": {
            "type": "array",
            "maxItems": 10,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "format": "uuid"
            }
          },
          "email_subject": {
            "type": "string",
            "maxLength": 500
          },
          "email_message": {
            "type": "string",
            "maxLength": 10000
          }
        }
      },
      "EnvelopeDraftMetadata": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "email_subject": {
            "type": "string",
            "maxLength": 500
          },
          "email_message": {
            "type": "string",
            "maxLength": 10000
          }
        }
      },
      "EnvelopeDraftRecipientInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "name": {
            "type": "string",
            "maxLength": 50,
            "minLength": 1,
            "pattern": "^[\\x00-\\x7F]+$"
          },
          "type": {
            "type": "string",
            "enum": [
              "signer",
              "viewer",
              "copy"
            ]
          },
          "priority": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          },
          "recipient_name": {
            "type": "string",
            "maxLength": 50,
            "nullable": true
          },
          "recipient_email": {
            "type": "string",
            "format": "email",
            "nullable": true,
            "maxLength": 100
          },
          "send_complete_email": {
            "type": "boolean"
          },
          "required_access_code": {
            "type": "boolean"
          },
          "access_code": {
            "type": "string",
            "maxLength": 50,
            "nullable": true,
            "writeOnly": true
          }
        },
        "required": [
          "name",
          "type",
          "priority"
        ]
      },
      "EnvelopeDraftRecipients": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "signing_order": {
            "type": "boolean",
            "default": false
          },
          "recipients": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/EnvelopeDraftRecipientInput"
            }
          }
        },
        "required": [
          "recipients"
        ]
      },
      "EnvelopeDraftSettings": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "expires_after_days": {
            "type": "integer",
            "minimum": 1,
            "maximum": 3650
          },
          "warning_before_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3650
          },
          "reminders_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3650
          },
          "first_reminder_after_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3650
          },
          "reminder_interval_days": {
            "type": "integer",
            "minimum": 0,
            "maximum": 3650
          },
          "expiration": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "signing_template_id": {
            "type": "string",
            "format": "uuid"
          },
          "sender_template_id": {
            "type": "string",
            "format": "uuid"
          },
          "inherit_signing_settings": {
            "type": "boolean",
            "enum": [
              true
            ]
          },
          "inherit_sender": {
            "type": "boolean",
            "enum": [
              true
            ]
          }
        },
        "description": "Existing signing flows enforce expiration. expires_after_days is 1–3650; drafts default to 120. Send rejects a draft past the existing creation-based expiry window. Inherited signing/sender configuration can be selected from the account or an owned template snapshot."
      },
      "EnvelopeSend": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "send_email": {
            "type": "boolean",
            "description": "Required explicit choice. false activates signing sessions without sending invitations; true invokes existing delivery after commit."
          }
        },
        "required": [
          "send_email"
        ]
      },
      "EnvelopeDraftRecipient": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "type": {
            "type": "string",
            "enum": [
              "signer",
              "viewer",
              "copy"
            ]
          },
          "priority": {
            "type": "integer"
          },
          "recipient_name": {
            "type": "string",
            "nullable": true
          },
          "recipient_email": {
            "type": "string",
            "nullable": true
          },
          "send_complete_email": {
            "type": "boolean"
          },
          "required_access_code": {
            "type": "boolean"
          },
          "has_access_code": {
            "type": "boolean"
          },
          "recipient_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "status_code": {
            "type": "integer",
            "nullable": true
          }
        },
        "required": [
          "name",
          "type",
          "priority",
          "id",
          "has_access_code"
        ]
      },
      "EnvelopeDefinition": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "status_code": {
            "type": "integer"
          },
          "email_subject": {
            "type": "string",
            "nullable": true
          },
          "email_message": {
            "type": "string",
            "nullable": true
          },
          "signing_order": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "sent_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "settings": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "expires_after_days": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3650,
                "nullable": true
              },
              "warning_before_days": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3650,
                "nullable": true
              },
              "reminders_days": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3650,
                "nullable": true
              },
              "first_reminder_after_days": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3650,
                "nullable": true
              },
              "reminder_interval_days": {
                "type": "integer",
                "minimum": 0,
                "maximum": 3650,
                "nullable": true
              },
              "expiration": {
                "type": "integer",
                "enum": [
                  0,
                  1
                ],
                "nullable": true
              },
              "signing_template_id": {
                "type": "string",
                "format": "uuid",
                "nullable": true
              },
              "sender_template_id": {
                "type": "string",
                "format": "uuid",
                "nullable": true
              }
            }
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateFileDefinition"
            }
          },
          "recipients": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnvelopeDraftRecipient"
            }
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateFieldDefinition"
            }
          }
        },
        "required": [
          "envelope_id",
          "status_code",
          "files",
          "recipients",
          "fields",
          "settings"
        ]
      },
      "EnvelopeDefinitionResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/EnvelopeDefinition"
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "data",
          "requestId"
        ]
      },
      "EnvelopeDraftReceipt": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "applied": {
            "type": "boolean"
          },
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "file_id": {
            "type": "string",
            "format": "uuid"
          },
          "email_sending": {
            "type": "boolean"
          },
          "delivery_warning": {
            "type": "boolean"
          },
          "delivery_status": {
            "type": "string",
            "description": "queued means persisted in the durable outbox, not accepted by the mail provider or delivered to an inbox.",
            "enum": [
              "queued",
              "not_requested",
              "submitted",
              "not_confirmed"
            ]
          }
        },
        "required": [
          "applied",
          "envelope_id"
        ]
      },
      "EnvelopeDraftMutationResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/EnvelopeDraftReceipt"
          },
          "requestId": {
            "type": "string"
          },
          "operationId": {
            "type": "string",
            "format": "uuid"
          },
          "resourceId": {
            "type": "string",
            "format": "uuid"
          }
        },
        "required": [
          "data",
          "requestId",
          "operationId"
        ]
      },
      "EnvelopeListItem": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "status_code": {
            "type": "integer",
            "nullable": true
          },
          "email_subject": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "sent_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "EnvelopeActivityItem": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "event_id": {
            "type": "string",
            "format": "uuid"
          },
          "action": {
            "type": "string",
            "nullable": true
          },
          "object_type": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "error_code": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "EnvelopeList": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnvelopeListItem"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "page_size"
        ]
      },
      "EnvelopeListResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/EnvelopeList"
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "data",
          "requestId"
        ]
      },
      "EnvelopeActivity": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EnvelopeActivityItem"
            }
          },
          "total": {
            "type": "integer",
            "minimum": 0
          },
          "page": {
            "type": "integer",
            "minimum": 1
          },
          "page_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 200
          }
        },
        "required": [
          "items",
          "total",
          "page",
          "page_size"
        ]
      },
      "EnvelopeActivityResponse": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "data": {
            "$ref": "#/components/schemas/EnvelopeActivity"
          },
          "requestId": {
            "type": "string"
          }
        },
        "required": [
          "data",
          "requestId"
        ]
      },
      "Delivery": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "delivery_id",
          "envelope_id",
          "parent_delivery_id",
          "channel",
          "kind",
          "state",
          "attempts",
          "outcome",
          "next_attempt_at",
          "created_at",
          "updated_at",
          "completed_at",
          "error_code"
        ],
        "properties": {
          "delivery_id": {
            "type": "string",
            "format": "uuid"
          },
          "envelope_id": {
            "type": "string",
            "format": "uuid"
          },
          "parent_delivery_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "channel": {
            "type": "string",
            "enum": [
              "email",
              "webhook",
              "pdf"
            ]
          },
          "kind": {
            "type": "string",
            "enum": [
              "envelope_mail",
              "graph_mail",
              "smtp_mail",
              "webhook",
              "pdf"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "completed",
              "dead"
            ]
          },
          "attempts": {
            "type": "integer",
            "minimum": 0
          },
          "outcome": {
            "type": "string",
            "nullable": true,
            "enum": [
              null,
              "fanout_completed",
              "provider_accepted",
              "receiver_accepted",
              "generated"
            ]
          },
          "next_attempt_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "completed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "error_code": {
            "type": "string",
            "nullable": true,
            "maxLength": 64
          }
        }
      },
      "DeliveryResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Delivery"
          },
          "requestId": {
            "type": "string"
          }
        }
      },
      "DeliveryPageResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "requestId"
        ],
        "properties": {
          "requestId": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "items",
              "total",
              "page",
              "page_size"
            ],
            "properties": {
              "items": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Delivery"
                }
              },
              "total": {
                "type": "integer",
                "minimum": 0
              },
              "page": {
                "type": "integer",
                "minimum": 1
              },
              "page_size": {
                "type": "integer",
                "minimum": 1,
                "maximum": 200
              }
            }
          }
        }
      }
    },
    "responses": {
      "Error400": {
        "description": "Invalid request, unknown/duplicate properties or missing key.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error401": {
        "description": "Invalid or expired credentials.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error403": {
        "description": "Resource access denied.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error404": {
        "description": "Route or operation not found.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error405": {
        "description": "Unsupported method.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error409": {
        "description": "Invalid state, changed read, key conflict or uncertain operation; inspect error.code.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error413": {
        "description": "JSON body exceeds 1 MiB.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error415": {
        "description": "Only application/json request bodies are supported.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error422": {
        "description": "Document content cannot be processed.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error500": {
        "description": "Internal error or operation outcome uncertain.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error503": {
        "description": "service_unavailable: operation store unavailable before starting a mutation. audit_unavailable: audit could not be persisted before business execution, so no business action started. audit_outcome_unconfirmed: execution may have completed but the final audit event was not persisted; retain the same idempotency key, use Operation-Id when available and reconcile before retrying. Never infer rollback from HTTP 503.",
        "headers": {
          "Operation-Id": {
            "description": "Present when a durable mutation receipt is known. Poll that operation before any new intent.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error412": {
        "description": "ETag mismatch; no update applied by this request.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Error428": {
        "description": "If-Match is required.",
        "headers": {
          "X-Request-Id": {
            "description": "Server-generated correlation identifier.",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
