{
  "openapi": "3.1.0",
  "info": {
    "title": "SignYoDoc API",
    "version": "1.0.0",
    "description": "Send documents for legally binding e-signature, track signing status, and download signed PDFs - built for AI agents and automation. Authenticate with a workspace API key (Settings > API Token in the app). The same key also works with the hosted MCP server at https://signyodoc.com/api/mcp. Sending rules: SignYoDoc runs on credits that never expire. A send costs 1 credit per recipient, charged from the workspace balance; when the balance cannot cover a send the API returns 403 insufficient_credits with the balance and the required amount. Signing documents sent to you is always free.",
    "contact": {
      "name": "SignYoDoc",
      "url": "https://signyodoc.com/developers"
    }
  },
  "servers": [
    {
      "url": "https://signyodoc.com/api/v1",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Your SignYoDoc API key (starts with syd_)."
      },
      "apiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key"
      }
    },
    "schemas": {
      "Recipient": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "name": {
            "type": "string",
            "example": "Priya Shah"
          },
          "email": {
            "type": "string",
            "format": "email",
            "example": "priya@example.com"
          },
          "access_code": {
            "type": "string",
            "minLength": 4,
            "maxLength": 64,
            "description": "Optional. When set, the signer must enter this code after opening the signing link before they can view or sign. You must share the code with the signer yourself; it is never stored in plain text or returned by the API."
          }
        }
      },
      "Field": {
        "type": "object",
        "required": [
          "recipient_email",
          "type",
          "page"
        ],
        "properties": {
          "recipient_email": {
            "type": "string",
            "format": "email"
          },
          "type": {
            "type": "string",
            "enum": [
              "signature",
              "initials",
              "date",
              "text",
              "name",
              "email",
              "checkbox",
              "radio",
              "dropdown",
              "image"
            ]
          },
          "page": {
            "type": "integer",
            "minimum": 1,
            "description": "1-based page number."
          },
          "x": {
            "type": "number",
            "description": "Left edge in PDF points from the page left edge. Default 72."
          },
          "y": {
            "type": "number",
            "description": "Top edge in PDF points from the page top edge. Default 480."
          },
          "width": {
            "type": "number"
          },
          "height": {
            "type": "number"
          },
          "required": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "awaiting_signatures",
              "completed",
              "declined",
              "expired"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "signers": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "email": {
                  "type": "string"
                },
                "signed": {
                  "type": "boolean"
                },
                "signed_at": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date-time"
                }
              }
            }
          },
          "signed_count": {
            "type": "integer"
          },
          "signer_count": {
            "type": "integer"
          },
          "note": {
            "type": "string"
          },
          "send_in_order": {
            "type": "boolean"
          },
          "pending_signing_links": {
            "type": "array",
            "description": "Signing links for signers who have not signed yet (detail responses only).",
            "items": {
              "type": "object",
              "properties": {
                "email": {
                  "type": "string"
                },
                "signing_url": {
                  "type": "string"
                }
              }
            }
          },
          "invites": {
            "type": "array",
            "description": "Present on send responses: one entry per recipient with their signing link and email delivery status.",
            "items": {
              "type": "object",
              "properties": {
                "email": {
                  "type": "string"
                },
                "signing_url": {
                  "type": "string",
                  "description": "This signer's personal signing link."
                },
                "email_status": {
                  "type": "string",
                  "enum": [
                    "sent",
                    "failed",
                    "skipped",
                    "queued_in_order"
                  ],
                  "description": "sent = invite email delivered to the mail provider; queued_in_order = emailed when the previous signer finishes (send_in_order)."
                }
              }
            }
          },
          "download_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set when the document is completed."
          },
          "certificate_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Set when the completion certificate exists."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "example": "insufficient_credits"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      }
    }
  },
  "paths": {
    "/me": {
      "get": {
        "operationId": "getAccountInfo",
        "summary": "Workspace, plan and send usage for this API key",
        "responses": {
          "200": {
            "description": "Account info"
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents": {
      "get": {
        "operationId": "listDocuments",
        "summary": "List documents in the workspace",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "awaiting_signatures",
                "completed",
                "declined",
                "expired"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 25,
              "maximum": 100
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of documents",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "documents": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "draft",
                              "awaiting_signatures",
                              "completed",
                              "declined",
                              "expired"
                            ]
                          },
                          "created_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "sent_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "expires_at": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "format": "date-time"
                          },
                          "signers": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "name": {
                                  "type": "string"
                                },
                                "email": {
                                  "type": "string"
                                },
                                "signed": {
                                  "type": "boolean"
                                },
                                "signed_at": {
                                  "type": [
                                    "string",
                                    "null"
                                  ],
                                  "format": "date-time"
                                }
                              }
                            }
                          },
                          "signed_count": {
                            "type": "integer"
                          },
                          "signer_count": {
                            "type": "integer"
                          },
                          "note": {
                            "type": "string"
                          },
                          "send_in_order": {
                            "type": "boolean"
                          },
                          "pending_signing_links": {
                            "type": "array",
                            "description": "Signing links for signers who have not signed yet (detail responses only).",
                            "items": {
                              "type": "object",
                              "properties": {
                                "email": {
                                  "type": "string"
                                },
                                "signing_url": {
                                  "type": "string"
                                }
                              }
                            }
                          },
                          "invites": {
                            "type": "array",
                            "description": "Present on send responses: one entry per recipient with their signing link and email delivery status.",
                            "items": {
                              "type": "object",
                              "properties": {
                                "email": {
                                  "type": "string"
                                },
                                "signing_url": {
                                  "type": "string",
                                  "description": "This signer's personal signing link."
                                },
                                "email_status": {
                                  "type": "string",
                                  "enum": [
                                    "sent",
                                    "failed",
                                    "skipped",
                                    "queued_in_order"
                                  ],
                                  "description": "sent = invite email delivered to the mail provider; queued_in_order = emailed when the previous signer finishes (send_in_order)."
                                }
                              }
                            }
                          },
                          "download_url": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "Set when the document is completed."
                          },
                          "certificate_url": {
                            "type": [
                              "string",
                              "null"
                            ],
                            "description": "Set when the completion certificate exists."
                          }
                        }
                      }
                    },
                    "total": {
                      "type": "integer"
                    },
                    "limit": {
                      "type": "integer"
                    },
                    "offset": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createDocument",
        "summary": "Upload a PDF and create a document (optionally send it in the same call)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "file_base64"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "example": "Consulting Agreement"
                  },
                  "note": {
                    "type": "string",
                    "example": "Please review and sign"
                  },
                  "filename": {
                    "type": "string",
                    "example": "agreement.pdf"
                  },
                  "file_base64": {
                    "type": "string",
                    "description": "Base64-encoded PDF bytes (max 25 MB)."
                  },
                  "expires_in_days": {
                    "type": "integer",
                    "default": 15
                  },
                  "send": {
                    "type": "boolean",
                    "default": false,
                    "description": "When true, recipients is required and the document is sent immediately (invite emails go out and the send counts toward the monthly limit)."
                  },
                  "recipients": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "Priya Shah"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "example": "priya@example.com"
                        },
                        "access_code": {
                          "type": "string",
                          "minLength": 4,
                          "maxLength": 64,
                          "description": "Optional. When set, the signer must enter this code after opening the signing link before they can view or sign. You must share the code with the signer yourself; it is never stored in plain text or returned by the API."
                        }
                      }
                    },
                    "maxItems": 10
                  },
                  "fields": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "recipient_email",
                        "type",
                        "page"
                      ],
                      "properties": {
                        "recipient_email": {
                          "type": "string",
                          "format": "email"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "signature",
                            "initials",
                            "date",
                            "text",
                            "name",
                            "email",
                            "checkbox",
                            "radio",
                            "dropdown",
                            "image"
                          ]
                        },
                        "page": {
                          "type": "integer",
                          "minimum": 1,
                          "description": "1-based page number."
                        },
                        "x": {
                          "type": "number",
                          "description": "Left edge in PDF points from the page left edge. Default 72."
                        },
                        "y": {
                          "type": "number",
                          "description": "Top edge in PDF points from the page top edge. Default 480."
                        },
                        "width": {
                          "type": "number"
                        },
                        "height": {
                          "type": "number"
                        },
                        "required": {
                          "type": "boolean",
                          "default": true
                        }
                      }
                    },
                    "description": "Optional field placements. Omit to give every signer one signature field at the bottom of the last page."
                  },
                  "send_in_order": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created (and sent, when send=true). Includes per-recipient signing links and email status."
          },
          "400": {
            "description": "Validation error (file, recipients, fields)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Insufficient credit balance for this send",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents/from-template": {
      "post": {
        "operationId": "createDocumentFromTemplate",
        "summary": "Create a document from a template and optionally send it",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "template_id",
                  "recipients"
                ],
                "properties": {
                  "template_id": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "note": {
                    "type": "string"
                  },
                  "recipients": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "Priya Shah"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "example": "priya@example.com"
                        },
                        "access_code": {
                          "type": "string",
                          "minLength": 4,
                          "maxLength": 64,
                          "description": "Optional. When set, the signer must enter this code after opening the signing link before they can view or sign. You must share the code with the signer yourself; it is never stored in plain text or returned by the API."
                        }
                      }
                    },
                    "description": "One recipient per signer slot in the template, in order."
                  },
                  "send": {
                    "type": "boolean",
                    "default": false
                  },
                  "send_in_order": {
                    "type": "boolean",
                    "default": false
                  },
                  "expires_in_days": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created (and sent, when send=true)"
          },
          "400": {
            "description": "Validation error, including recipient/signer-slot count mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Insufficient credit balance for this send",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Template not found in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}": {
      "get": {
        "operationId": "getDocument",
        "summary": "Get one document with signer states and pending signing links",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Document detail"
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Document not found in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/send": {
      "post": {
        "operationId": "sendDocument",
        "summary": "Send a draft document to recipients for signature",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "recipients"
                ],
                "properties": {
                  "recipients": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "email"
                      ],
                      "properties": {
                        "name": {
                          "type": "string",
                          "example": "Priya Shah"
                        },
                        "email": {
                          "type": "string",
                          "format": "email",
                          "example": "priya@example.com"
                        },
                        "access_code": {
                          "type": "string",
                          "minLength": 4,
                          "maxLength": 64,
                          "description": "Optional. When set, the signer must enter this code after opening the signing link before they can view or sign. You must share the code with the signer yourself; it is never stored in plain text or returned by the API."
                        }
                      }
                    },
                    "maxItems": 10
                  },
                  "fields": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "recipient_email",
                        "type",
                        "page"
                      ],
                      "properties": {
                        "recipient_email": {
                          "type": "string",
                          "format": "email"
                        },
                        "type": {
                          "type": "string",
                          "enum": [
                            "signature",
                            "initials",
                            "date",
                            "text",
                            "name",
                            "email",
                            "checkbox",
                            "radio",
                            "dropdown",
                            "image"
                          ]
                        },
                        "page": {
                          "type": "integer",
                          "minimum": 1,
                          "description": "1-based page number."
                        },
                        "x": {
                          "type": "number",
                          "description": "Left edge in PDF points from the page left edge. Default 72."
                        },
                        "y": {
                          "type": "number",
                          "description": "Top edge in PDF points from the page top edge. Default 480."
                        },
                        "width": {
                          "type": "number"
                        },
                        "height": {
                          "type": "number"
                        },
                        "required": {
                          "type": "boolean",
                          "default": true
                        }
                      }
                    }
                  },
                  "send_in_order": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sent. Includes signing links and per-recipient email status."
          },
          "400": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Insufficient credit balance for this send",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Document not found in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Document already sent, completed or declined",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/self-sign": {
      "post": {
        "operationId": "selfSignDocument",
        "summary": "The workspace owner signs their own document (no other signers)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "signature_png_base64": {
                    "type": "string",
                    "description": "Optional PNG of a drawn signature. Omit to sign with the owner name rendered in a script style."
                  },
                  "signature_text": {
                    "type": "string",
                    "description": "Optional name to render when no signature image is given. Defaults to the workspace owner name."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Signed and completed"
          },
          "400": {
            "description": "Document has other signers, or the signature image is invalid",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Document not found in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Document already completed or declined",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/download": {
      "get": {
        "operationId": "downloadSignedDocument",
        "summary": "Download the signed PDF (only once the document is completed)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The signed PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Document not found in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Document not completed yet",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/documents/{id}/certificate": {
      "get": {
        "operationId": "downloadCertificate",
        "summary": "Download the completion certificate PDF (audit trail)",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The completion certificate PDF",
            "content": {
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Document not found in this workspace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "Certificate not ready (document not completed)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/templates": {
      "get": {
        "operationId": "listTemplates",
        "summary": "List templates in the workspace with their signer slot counts",
        "responses": {
          "200": {
            "description": "Templates"
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "example": "insufficient_credits"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
