{
  "openapi": "3.1.0",
  "info": {
    "title": "DocuDetect API",
    "version": "1",
    "description": "Make documents from a PDF or a template, send them to their signers, and track them to the signed PDF. Every response is `{ success: true, data }`; every failure is `{ success: false, status, message, code }`. No response ever contains a signing link: people get theirs by email.\n\nAuthenticate with an account API key (Settings → Developers): `Authorization: Bearer dd_live_…`. Keys are shown once; keep them on a server. A key acts only for the account that made it.\n\nPermissions:\n- `documents:read` (See your documents): Titles, status, signers, history and the PDFs.\n- `documents:write` (Make drafts): Upload a PDF or use a template to make a draft. It can't send it or email anyone.\n- `documents:send` (Email your signers): Sending, reminders and canceling. Every email counts against your daily email limit and goes through the same checks as the app.\n- `templates:read` (See your templates): Your templates and the signers each one needs. Using one to make a draft also needs Make drafts.\n- `webhooks:manage` (Add and change webhooks): It can send your events to any public address. Revoking the key turns its webhooks off.\n- `embedding:sessions` (Open embedded signing sessions): Whoever holds this key can open a signing session for anyone you add as signing inside your app, and so can sign for them.\n\nLimits: 300 calls a minute per key, of which 60 may be changes (600 and 120 for all of an account's keys together), plus the account's own limits, which keys share with the app (new documents an hour, emails a day, the plan's counts). Lists use cursors: pass `nextCursor` back as `cursor` until it is null. Responses may gain fields; ignore the ones you don't know. Bodies and query strings with unknown fields are refused.\n\nIdempotency: creates and calls that email people take an `Idempotency-Key` header. Retrying with the same key and body returns the first response instead of acting twice."
  },
  "servers": [
    {
      "url": "https://docudetect.com/api/public/v1"
    }
  ],
  "tags": [
    {
      "name": "Account"
    },
    {
      "name": "Documents"
    },
    {
      "name": "Templates"
    },
    {
      "name": "Webhooks"
    }
  ],
  "paths": {
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "tags": [
          "Account"
        ],
        "summary": "This API's OpenAPI 3.1 document",
        "security": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "This document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Account"
        ],
        "summary": "The account and key making the call",
        "description": "Use it to test a connection.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Me"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents": {
      "get": {
        "operationId": "listDocuments",
        "tags": [
          "Documents"
        ],
        "summary": "List documents",
        "description": "Newest first. With `updatedSince`, oldest change first, so a poller can keep the last `updatedAt` it saw and ask again.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:read"
        ],
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only documents in this state.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "sent",
                "completed",
                "canceled"
              ]
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "required": false,
            "description": "Only documents changed at or after this time, oldest change first: poll with the last `updatedAt` you saw.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1 to 100.",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` of the previous page.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DocumentPage"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Make a draft from a PDF",
        "description": "`multipart/form-data` with the PDF as `file` (up to 20 MB). Optionally name the signer and place fields; otherwise finish the draft in the app. Nothing is emailed. Counts against the account's new documents an hour, like the app.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:write"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string of 1 to 255 printable ASCII characters (a UUID, say). A retry with the same key and body gets the first call's response (with `Idempotent-Replayed: true`) instead of acting twice; the same key with a different body is 422. A refused call (any 4xx) leaves the key free, so fix the request and retry with the same key. A call that started and failed (a 5xx) keeps its answer: read the document before you repeat an action. Kept 24 hours, per API key.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "The PDF, up to 20 MB."
                  },
                  "title": {
                    "description": "Defaults to the file name.",
                    "type": "string",
                    "maxLength": 200
                  },
                  "signerName": {
                    "description": "The signer's name (with signerEmail).",
                    "type": "string",
                    "maxLength": 200
                  },
                  "signerEmail": {
                    "description": "The signer's email (with signerName).",
                    "type": "string",
                    "maxLength": 254
                  },
                  "fields": {
                    "description": "A JSON array of fields, as the editor saves them: `{ id, type: signature|initials|text|date|checkbox, page, x, y, width, height, required?, label?, value? }`, positions as fractions of the page (0 to 1, from the top left). Leave it out to place fields in the app.",
                    "type": "string",
                    "maxLength": 262144
                  }
                },
                "required": [
                  "file"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier call with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "This Idempotency-Key was used for a different call (`idempotency_mismatch`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}": {
      "get": {
        "operationId": "getDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Get a document",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/events": {
      "get": {
        "operationId": "listDocumentEvents",
        "tags": [
          "Documents"
        ],
        "summary": "A document's history",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/DocumentEvents"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/pdf": {
      "get": {
        "operationId": "getDocumentPdf",
        "tags": [
          "Documents"
        ],
        "summary": "Download the signed or the original PDF",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          },
          {
            "name": "version",
            "in": "query",
            "required": false,
            "description": "`signed`: the completed PDF (409 until the document is completed). `original`: the PDF as uploaded.",
            "schema": {
              "default": "signed",
              "type": "string",
              "enum": [
                "signed",
                "original"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF file.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/certificate": {
      "get": {
        "operationId": "getDocumentCertificate",
        "tags": [
          "Documents"
        ],
        "summary": "Download the certificate of completion",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF file.",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/send": {
      "post": {
        "operationId": "sendDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Send a draft to its signers",
        "description": "Emails each signer of the first step their signing request. Goes through the same checks as the app: account standing, a verified email, young-account limits, the daily email limit and scam-title review; a refused send answers with its `code` (`held_for_review`, `email_unverified`, `new_account_limit`, ...). Sending a document that is already out returns it as it is.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:send"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string of 1 to 255 printable ASCII characters (a UUID, say). A retry with the same key and body gets the first call's response (with `Idempotent-Replayed: true`) instead of acting twice; the same key with a different body is 422. A refused call (any 4xx) leaves the key free, so fix the request and retry with the same key. A call that started and failed (a 5xx) keeps its answer: read the document before you repeat an action. Kept 24 hours, per API key.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "description": "Optional. Send an empty object or no body.",
                "type": "object",
                "properties": {
                  "revision": {
                    "description": "Send only if the document is still at this revision (409 otherwise).",
                    "type": "integer",
                    "minimum": 0
                  },
                  "delivery": {
                    "description": "`email` (the default) emails the signer their signing request. `embedded` (one signer, embedded signing on) emails nobody and sends no automatic reminders: the signer signs inside your app through an embedded session.",
                    "type": "string",
                    "enum": [
                      "email",
                      "embedded"
                    ]
                  }
                },
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier call with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "This Idempotency-Key was used for a different call (`idempotency_mismatch`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable (`unavailable`); retry shortly with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/remind": {
      "post": {
        "operationId": "remindDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Remind the signers whose turn it is",
        "description": "At most once every 10 minutes per document (429 `recently_reminded` otherwise).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:send"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string of 1 to 255 printable ASCII characters (a UUID, say). A retry with the same key and body gets the first call's response (with `Idempotent-Replayed: true`) instead of acting twice; the same key with a different body is 422. A refused call (any 4xx) leaves the key free, so fix the request and retry with the same key. A call that started and failed (a 5xx) keeps its answer: read the document before you repeat an action. Kept 24 hours, per API key.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "description": "No fields. Send an empty object or no body.",
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier call with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "This Idempotency-Key was used for a different call (`idempotency_mismatch`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable (`unavailable`); retry shortly with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/cancel": {
      "post": {
        "operationId": "cancelDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Cancel a document that is waiting for signatures",
        "description": "Every signing link stops working. Signers who were already emailed a link are told it was canceled.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "documents:send"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string of 1 to 255 printable ASCII characters (a UUID, say). A retry with the same key and body gets the first call's response (with `Idempotent-Replayed: true`) instead of acting twice; the same key with a different body is 422. A refused call (any 4xx) leaves the key free, so fix the request and retry with the same key. A call that started and failed (a 5xx) keeps its answer: read the document before you repeat an action. Kept 24 hours, per API key.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "description": "No fields. Send an empty object or no body.",
                "type": "object",
                "properties": {},
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier call with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "This Idempotency-Key was used for a different call (`idempotency_mismatch`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable (`unavailable`); retry shortly with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/signers/{signerId}/embedded-session": {
      "post": {
        "operationId": "createEmbeddedSession",
        "tags": [
          "Documents"
        ],
        "summary": "Make a one-time embedded signing link for a signer whose turn it is",
        "description": "For signing inside your own app: show `url` in an iframe on `origin`, which must be a verified domain under Settings → Developers → Embedded signing. Whoever opens the link signs as that signer, so put it only in front of them. The link opens once, within 5 minutes, and then works for 60 minutes in that frame. Nothing is emailed. Each call makes a new link; opening one ends the earlier ones.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "embedding:sessions"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          },
          {
            "name": "signerId",
            "in": "path",
            "required": true,
            "description": "The signer: `s1` on a one-signer document, otherwise the signer's `id`.",
            "schema": {
              "type": "string",
              "pattern": "^(s1|s_[a-f0-9]{8})$"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "description": "Where the session will be framed.",
                "type": "object",
                "properties": {
                  "origin": {
                    "description": "The domain of the page that frames the signing page, such as `app.example.com` (or `https://app.example.com`). It must be a verified domain.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 300
                  }
                },
                "required": [
                  "origin"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/EmbeddedSession"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/templates": {
      "get": {
        "operationId": "listTemplates",
        "tags": [
          "Templates"
        ],
        "summary": "List templates",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "templates:read"
        ],
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Matches the template name.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Items per page, 1 to 100.",
            "schema": {
              "default": 50,
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "The `nextCursor` of the previous page.",
            "schema": {
              "type": "string",
              "maxLength": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/TemplatePage"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/templates/{id}": {
      "get": {
        "operationId": "getTemplate",
        "tags": [
          "Templates"
        ],
        "summary": "Get a template, with its signers and the fields you fill before sending",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "templates:read"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Template"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/templates/{id}/use": {
      "post": {
        "operationId": "useTemplate",
        "tags": [
          "Templates"
        ],
        "summary": "Make a draft from a template",
        "description": "A new draft with the template's PDF, fields and questions, and the people you name. Nothing is emailed: send it with POST /documents/{id}/send.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "templates:read",
          "documents:write"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A document or template id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string of 1 to 255 printable ASCII characters (a UUID, say). A retry with the same key and body gets the first call's response (with `Idempotent-Replayed: true`) instead of acting twice; the same key with a different body is 422. A refused call (any 4xx) leaves the key free, so fix the request and retry with the same key. A call that started and failed (a 5xx) keeps its answer: read the document before you repeat an action. Kept 24 hours, per API key.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "signers": {
                    "description": "One person for each of the template's signers.",
                    "minItems": 1,
                    "maxItems": 20,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "description": "Their full name, as it appears in the email and the certificate.",
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "email": {
                          "description": "Where the signing request goes.",
                          "type": "string",
                          "minLength": 3,
                          "maxLength": 254
                        },
                        "role": {
                          "description": "The template signer's `id` (from GET /templates/{id}).",
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        }
                      },
                      "required": [
                        "name",
                        "email",
                        "role"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "copies": {
                    "description": "Several-signer templates: people who get a copy when everyone has signed.",
                    "maxItems": 10,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "description": "Their full name, as it appears in the email and the certificate.",
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 200
                        },
                        "email": {
                          "description": "Where the signing request goes.",
                          "type": "string",
                          "minLength": 3,
                          "maxLength": 254
                        }
                      },
                      "required": [
                        "name",
                        "email"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "title": {
                    "description": "Added to the template's name: \"<template>: <title>\".",
                    "type": "string",
                    "maxLength": 200
                  },
                  "values": {
                    "description": "Values for the fields you fill before sending (`senderFields` of the template).",
                    "maxItems": 500,
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "fieldId": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 80
                        },
                        "value": {
                          "type": "string",
                          "maxLength": 5000
                        }
                      },
                      "required": [
                        "fieldId",
                        "value"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "signers"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              },
              "Idempotent-Replayed": {
                "description": "`true` when this is the stored response to an earlier call with the same Idempotency-Key.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "This Idempotency-Key was used for a different call (`idempotency_mismatch`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints": {
      "get": {
        "operationId": "listWebhookEndpoints",
        "tags": [
          "Webhooks"
        ],
        "summary": "List webhook endpoints",
        "description": "Every endpoint of the account. Ones this key made are shown in full; others with a masked address.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "webhooks:manage"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/WebhookEndpointList"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Add a webhook endpoint (subscribe)",
        "description": "DocuDetect POSTs each chosen `document.*` event to the address, signed in the `DocuDetect-Signature` header with the secret this returns once. Payloads carry ids, types and times only. Counts against the plan's webhook endpoints (Free 1). Not idempotent: a retry after a timeout may add a second endpoint, so list first. Revoking the key turns its endpoints off.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "webhooks:manage"
        ],
        "parameters": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "url": {
                    "description": "A public https:// address on the standard port. Local and private addresses are refused.",
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 2048
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "events": {
                    "description": "`[\"*\"]` for every event (including ones added later), or a list of `document.*` names.",
                    "anyOf": [
                      {
                        "type": "array",
                        "prefixItems": [
                          {
                            "type": "string",
                            "const": "*"
                          }
                        ]
                      },
                      {
                        "minItems": 1,
                        "maxItems": 35,
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "document.created",
                            "document.sent",
                            "document.viewed",
                            "document.reminded",
                            "document.email_bounced",
                            "document.link_renewed",
                            "document.recipient_changed",
                            "document.signed",
                            "document.completed",
                            "document.canceled",
                            "document.declined",
                            "document.reopened",
                            "document.expired",
                            "document.held_for_review",
                            "document.duplicated",
                            "document.deleted",
                            "document.copy_emailed",
                            "document.source_replaced",
                            "document.signers_changed",
                            "document.link_requested",
                            "document.verified",
                            "document.reminders_paused",
                            "document.reminders_resumed",
                            "document.cancel_notified",
                            "document.step_started",
                            "document.signer_activated",
                            "document.expiry_extended",
                            "document.in_person_started",
                            "document.in_person_ended",
                            "document.signers_suggested_accepted",
                            "document.approval_requested",
                            "document.approved",
                            "document.sent_back",
                            "document.approval_withdrawn",
                            "document.embedded_session_opened"
                          ]
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "url",
                  "events"
                ],
                "additionalProperties": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/WebhookEndpointCreated"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Not possible in the document's current state, or it changed meanwhile (`conflict`, `several_signers`, `template_not_ready`, `idempotency_in_progress` with `Retry-After`, `idempotency_replay_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Temporarily unavailable (`unavailable`); retry shortly with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/webhook-endpoints/{id}": {
      "delete": {
        "operationId": "deleteWebhookEndpoint",
        "tags": [
          "Webhooks"
        ],
        "summary": "Delete a webhook endpoint (unsubscribe)",
        "description": "Only an endpoint this key made, or one a revoked or expired key left behind (403 `not_yours` otherwise).",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-required-scopes": [
          "webhooks:manage"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "A webhook endpoint id.",
            "schema": {
              "type": "string",
              "pattern": "^[a-f0-9]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/WebhookEndpointDeleted"
                    }
                  },
                  "required": [
                    "success",
                    "data"
                  ]
                }
              }
            },
            "headers": {
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (`invalid_request`), or a document that isn't ready for this (the message says what to fix).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Missing, unknown, expired or revoked key (`invalid_api_key`).",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer realm=\"docudetect\"",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "The key lacks a permission (`insufficient_scope`), the account is suspended (`account_suspended`), a plan limit is reached (`limit_*`), or the abuse guard refused a send (`held_for_review`, `email_unverified`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found in this account (`not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "413": {
            "description": "The body is too large (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Too many calls (`rate_limited`), a reminder sent less than 10 minutes ago, the new-account or daily email limit (`new_account_limit`, `email_limit`). Every 429 carries `Retry-After`: wait that many seconds.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Limit": {
                "description": "Calls allowed per window for this key.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Remaining": {
                "description": "Calls left in the current window.",
                "schema": {
                  "type": "integer"
                }
              },
              "RateLimit-Reset": {
                "description": "Seconds until the window resets.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key, `dd_live_…`."
      }
    },
    "schemas": {
      "EmbeddedSession": {
        "description": "A one-time signing link to show in a frame on `origin`. It opens once, within 5 minutes; the signer then has 60 minutes to sign.",
        "type": "object",
        "properties": {
          "url": {
            "type": "string"
          },
          "expiresAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "origin": {
            "type": "string"
          }
        },
        "required": [
          "url",
          "expiresAt",
          "origin"
        ]
      },
      "Me": {
        "description": "The account and key making the call.",
        "type": "object",
        "properties": {
          "account": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              }
            },
            "required": [
              "name"
            ]
          },
          "key": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "displayPrefix": {
                "type": "string"
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "documents:read",
                    "documents:write",
                    "documents:send",
                    "templates:read",
                    "webhooks:manage",
                    "embedding:sessions"
                  ]
                }
              }
            },
            "required": [
              "name",
              "displayPrefix",
              "scopes"
            ]
          }
        },
        "required": [
          "account",
          "key"
        ]
      },
      "Signer": {
        "description": "A person who signs. A one-signer document has one, with id `s1`. Never carries a signing link: people get theirs by email.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "description": "The role, on several-signer documents (\"Buyer\").",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "step": {
            "description": "Signers in one step sign together; the next step starts when they all have.",
            "type": "integer"
          },
          "status": {
            "description": "`waiting`: their step hasn't started (or the document is a draft). `active`: emailed. `opened`: they opened it. `signed`, `declined`.",
            "type": "string",
            "enum": [
              "waiting",
              "active",
              "opened",
              "signed",
              "declined"
            ]
          },
          "emailBounced": {
            "description": "Their latest signing request could not be delivered.",
            "type": "boolean"
          },
          "emailRefused": {
            "description": "Why their signing request was not emailed when the account's sending checks refused it (`held_for_review`, `new_account_limit`, `email_unverified`, ...); null otherwise.",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "viewedAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "signedAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "label",
          "name",
          "email",
          "step",
          "status",
          "emailBounced",
          "emailRefused",
          "viewedAt",
          "signedAt"
        ]
      },
      "CopyPerson": {
        "description": "Someone who gets a copy when everyone has signed.",
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "email"
        ]
      },
      "Document": {
        "description": "A document: a PDF with fields, its signers and where it stands.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "description": "`sent` means waiting for signatures.",
            "type": "string",
            "enum": [
              "draft",
              "sent",
              "completed",
              "canceled"
            ]
          },
          "expired": {
            "description": "Sent, and the signing links expired before everyone signed.",
            "type": "boolean"
          },
          "heldForReview": {
            "description": "A draft our abuse guard stopped at send; nothing was emailed.",
            "type": "boolean"
          },
          "revision": {
            "description": "Changes with every edit and send.",
            "type": "integer"
          },
          "pageCount": {
            "type": "integer"
          },
          "fieldCount": {
            "type": "integer"
          },
          "signers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Signer"
            }
          },
          "copies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CopyPerson"
            }
          },
          "currentStep": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "folderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "templateId": {
            "description": "The template it was made from.",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdWithApiKey": {
            "description": "The API key that made it, by its name.",
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": [
                  "name"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "declined": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "signerId": {
                    "type": "string"
                  },
                  "reason": {
                    "anyOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "signerId",
                  "reason"
                ]
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "updatedAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "sentAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "expiresAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "completedAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "canceledAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "title",
          "status",
          "expired",
          "heldForReview",
          "revision",
          "pageCount",
          "fieldCount",
          "signers",
          "copies",
          "currentStep",
          "folderId",
          "templateId",
          "createdWithApiKey",
          "declined",
          "createdAt",
          "updatedAt",
          "sentAt",
          "expiresAt",
          "completedAt",
          "canceledAt"
        ]
      },
      "DocumentPage": {
        "description": "One page of documents. Pass `nextCursor` back as `cursor` until it is null.",
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Document"
            }
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "nextCursor"
        ]
      },
      "DocumentEvent": {
        "description": "Something that happened to a document. Thin: ids and types, never answers or field values.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "description": "`document.created`, `document.sent`, `document.viewed`, `document.signed`, `document.completed`, `document.canceled`, ...",
            "type": "string"
          },
          "at": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "actor": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "signerId": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ]
          },
          "data": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {}
          }
        },
        "required": [
          "id",
          "type",
          "at",
          "actor",
          "data"
        ]
      },
      "DocumentEvents": {
        "description": "A document's history, oldest first (at most 500).",
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentEvent"
            }
          }
        },
        "required": [
          "items"
        ]
      },
      "TemplateSigner": {
        "description": "A signer of a template: a role and its step. Name the person for each when you use the template.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "step": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "label",
          "step"
        ]
      },
      "TemplateSummary": {
        "description": "A saved document you can send again with new people.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "pageCount": {
            "type": "integer"
          },
          "fieldCount": {
            "type": "integer"
          },
          "signers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateSigner"
            }
          },
          "ready": {
            "description": "Whether it can be used now (every field has a signer, every signer signs).",
            "type": "boolean"
          },
          "folderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "useCount": {
            "type": "integer"
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "updatedAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "title",
          "pageCount",
          "fieldCount",
          "signers",
          "ready",
          "folderId",
          "useCount",
          "lastUsedAt",
          "createdAt",
          "updatedAt"
        ]
      },
      "Template": {
        "description": "A template with the fields you fill before sending.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "pageCount": {
            "type": "integer"
          },
          "fieldCount": {
            "type": "integer"
          },
          "signers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateSigner"
            }
          },
          "ready": {
            "description": "Whether it can be used now (every field has a signer, every signer signs).",
            "type": "boolean"
          },
          "folderId": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "useCount": {
            "type": "integer"
          },
          "lastUsedAt": {
            "anyOf": [
              {
                "format": "date-time",
                "description": "ISO 8601 date-time (UTC).",
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "createdAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "updatedAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "senderFields": {
            "description": "Fields you fill before sending (`values` when you use it).",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "type": {
                  "type": "string"
                }
              },
              "required": [
                "id",
                "label",
                "type"
              ]
            }
          }
        },
        "required": [
          "id",
          "title",
          "pageCount",
          "fieldCount",
          "signers",
          "ready",
          "folderId",
          "useCount",
          "lastUsedAt",
          "createdAt",
          "updatedAt",
          "senderFields"
        ]
      },
      "TemplatePage": {
        "description": "One page of templates (not archived), most recently edited first.",
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TemplateSummary"
            }
          },
          "nextCursor": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "items",
          "nextCursor"
        ]
      },
      "Error": {
        "description": "Every failure. `code` is stable; `message` is for people.",
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "status": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "description": "`invalid_request`, `invalid_api_key`, `insufficient_scope`, `account_suspended`, `not_found`, `conflict`, `too_large`, `rate_limited`, `unavailable`, `internal`, the idempotency codes, or a documents code such as `held_for_review`, `email_unverified`, `new_account_limit`, `limit_apiKeys`.",
            "type": "string"
          }
        },
        "required": [
          "success",
          "status",
          "message",
          "code"
        ]
      },
      "WebhookEndpoint": {
        "description": "A webhook endpoint. Endpoints this key made are shown in full (`managed: true`); others only with a masked address.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "disabledReason": {
            "type": "string",
            "enum": [
              "owner",
              "failing",
              "gone",
              "key_revoked"
            ]
          },
          "secretPrefix": {
            "type": "string"
          },
          "createdVia": {
            "type": "string",
            "enum": [
              "settings",
              "api"
            ]
          },
          "apiKeyName": {
            "type": "string"
          },
          "managed": {
            "description": "Whether this key may delete it: it made it, or a key that is now revoked or expired did.",
            "type": "boolean"
          },
          "lastSuccessAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "status",
          "createdVia",
          "managed"
        ]
      },
      "WebhookEndpointCreated": {
        "description": "The new endpoint and its signing secret. The secret is shown only here: store it to check the DocuDetect-Signature header.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "events": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "disabledReason": {
            "type": "string",
            "enum": [
              "owner",
              "failing",
              "gone",
              "key_revoked"
            ]
          },
          "secretPrefix": {
            "type": "string"
          },
          "createdVia": {
            "type": "string",
            "enum": [
              "settings",
              "api"
            ]
          },
          "apiKeyName": {
            "type": "string"
          },
          "managed": {
            "description": "Whether this key may delete it: it made it, or a key that is now revoked or expired did.",
            "type": "boolean"
          },
          "lastSuccessAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "createdAt": {
            "format": "date-time",
            "description": "ISO 8601 date-time (UTC).",
            "type": "string"
          },
          "secret": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "status",
          "createdVia",
          "managed",
          "secret"
        ]
      },
      "WebhookEndpointList": {
        "description": "Every webhook endpoint of the account.",
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEndpoint"
            }
          }
        },
        "required": [
          "items"
        ]
      },
      "WebhookEndpointDeleted": {
        "description": "The endpoint is gone; nothing more is sent to it.",
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          }
        },
        "required": [
          "id",
          "deleted"
        ]
      }
    }
  }
}
