{
  "swagger": "2.0",
  "info": {
    "title": "bSign",
    "description": "bSign is a Canadian e-signature service by Binarium. Send documents for signature from your bSign templates, follow them, download the signed PDFs, and start flows when documents are signed or completed.",
    "version": "1.0.0",
    "contact": {
      "name": "Binarium",
      "email": "support@binarium.ca",
      "url": "https://bsign.ca/integrations/"
    }
  },
  "host": "api.bsign.ca",
  "basePath": "/v1",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "securityDefinitions": {
    "api_key": {
      "type": "apiKey",
      "in": "header",
      "name": "X-API-Token"
    }
  },
  "security": [
    {
      "api_key": []
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "GetMe",
        "summary": "Who the token belongs to",
        "description": "Who the token belongs to.",
        "x-ms-visibility": "internal",
        "responses": {
          "200": {
            "description": "The account.",
            "schema": {
              "$ref": "#/definitions/Me"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/templates": {
      "get": {
        "operationId": "ListTemplates",
        "summary": "List templates",
        "description": "Your templates and those shared with you, most recently changed first.",
        "x-ms-visibility": "advanced",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "required": false,
            "type": "string",
            "x-ms-summary": "Search",
            "description": "Part of the name."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "x-ms-summary": "Limit",
            "description": "How many to return (1-100, default 25).",
            "x-ms-visibility": "advanced"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "type": "integer",
            "minimum": 1,
            "x-ms-summary": "Page",
            "description": "Which page (from 1).",
            "x-ms-visibility": "advanced"
          }
        ],
        "responses": {
          "200": {
            "description": "Templates.",
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "x-ms-summary": "Data",
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Template"
                  }
                },
                "page": {
                  "x-ms-summary": "Page",
                  "type": "integer"
                },
                "limit": {
                  "x-ms-summary": "Limit",
                  "type": "integer"
                },
                "hasMore": {
                  "x-ms-summary": "Has More",
                  "type": "boolean",
                  "description": "There is another page."
                }
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/templates/{id}": {
      "get": {
        "operationId": "GetTemplate",
        "summary": "Get a template, with its roles and fields",
        "description": "Get a template, with its roles and fields.",
        "x-ms-visibility": "advanced",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The template.",
            "x-ms-dynamic-values": {
              "operationId": "ListTemplates",
              "parameters": {
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The template.",
            "schema": {
              "$ref": "#/definitions/TemplateDetail"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/templates/{id}/schema": {
      "get": {
        "operationId": "GetTemplateSendSchema",
        "summary": "A template's send request, as a JSON Schema",
        "description": "The body POST /templates/{id}/send takes for this template, with its roles and fillable fields as properties (for tools that build forms from a schema).",
        "x-ms-visibility": "internal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The template.",
            "x-ms-dynamic-values": {
              "operationId": "ListTemplates",
              "parameters": {
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The schema.",
            "schema": {
              "type": "object",
              "properties": {
                "schema": {
                  "x-ms-summary": "Schema",
                  "type": "object"
                }
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/templates/{id}/send": {
      "post": {
        "operationId": "SendTemplate",
        "summary": "Send a document from a template",
        "description": "Makes a document from the template and sends it for signature. Give a recipient for every role the template leaves open (roles it already names can be given someone else). Fields are filled by name: ones the template fills in before sending are drawn into the document; recipients' fields start with the value and can be changed while signing.",
        "x-ms-visibility": "important",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Template",
            "description": "The template.",
            "x-ms-dynamic-values": {
              "operationId": "ListTemplates",
              "parameters": {
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "x-ms-dynamic-schema": {
                "operationId": "GetTemplateSendSchema",
                "parameters": {
                  "id": {
                    "parameter": "id"
                  }
                },
                "value-path": "schema"
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "The document, sent.",
            "schema": {
              "$ref": "#/definitions/Document"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/documents": {
      "get": {
        "operationId": "ListDocuments",
        "summary": "List documents",
        "description": "The documents you sent, most recently changed first.",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "type": "string",
            "enum": [
              "draft",
              "in_progress",
              "completed",
              "declined",
              "voided",
              "expired"
            ],
            "x-ms-summary": "Status"
          },
          {
            "name": "reference",
            "in": "query",
            "required": false,
            "type": "string",
            "x-ms-summary": "Reference",
            "description": "The exact reference."
          },
          {
            "name": "templateId",
            "in": "query",
            "required": false,
            "type": "string",
            "x-ms-summary": "Template ID",
            "description": "Made from this template."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "type": "string",
            "x-ms-summary": "Search",
            "description": "Part of the name."
          },
          {
            "name": "updatedSince",
            "in": "query",
            "required": false,
            "type": "string",
            "x-ms-summary": "Updated Since",
            "description": "Changed after this time (ISO 8601)."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "x-ms-summary": "Limit",
            "description": "How many to return (1-100, default 25).",
            "x-ms-visibility": "advanced"
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "type": "integer",
            "minimum": 1,
            "x-ms-summary": "Page",
            "description": "Which page (from 1).",
            "x-ms-visibility": "advanced"
          }
        ],
        "responses": {
          "200": {
            "description": "Documents.",
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "x-ms-summary": "Data",
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Document"
                  }
                },
                "page": {
                  "x-ms-summary": "Page",
                  "type": "integer"
                },
                "limit": {
                  "x-ms-summary": "Limit",
                  "type": "integer"
                },
                "hasMore": {
                  "x-ms-summary": "Has More",
                  "type": "boolean",
                  "description": "There is another page."
                }
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/documents/{id}": {
      "get": {
        "operationId": "GetDocument",
        "summary": "Get a document",
        "description": "Get a document.",
        "x-ms-visibility": "important",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Document",
            "description": "The document ID (from a trigger or another action), or pick one out for signature.",
            "x-ms-dynamic-values": {
              "operationId": "ListDocuments",
              "parameters": {
                "status": {
                  "value": "in_progress"
                },
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The document.",
            "schema": {
              "$ref": "#/definitions/Document"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/documents/{id}/file": {
      "get": {
        "operationId": "DownloadDocument",
        "summary": "Download the PDF",
        "description": "The document as it is now: signed and sealed once completed.",
        "x-ms-visibility": "important",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Document",
            "description": "The document ID (from a trigger or another action), or pick one out for signature.",
            "x-ms-dynamic-values": {
              "operationId": "ListDocuments",
              "parameters": {
                "status": {
                  "value": "in_progress"
                },
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The PDF.",
            "schema": {
              "type": "string",
              "format": "binary",
              "x-ms-summary": "File Content"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "produces": [
          "application/pdf",
          "application/json"
        ]
      }
    },
    "/documents/{id}/certificate": {
      "get": {
        "operationId": "DownloadCertificate",
        "summary": "Download the completion certificate",
        "description": "Download the completion certificate.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Document",
            "description": "The document ID (from a trigger or another action), or pick one out for signature.",
            "x-ms-dynamic-values": {
              "operationId": "ListDocuments",
              "parameters": {
                "status": {
                  "value": "in_progress"
                },
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The certificate (PDF).",
            "schema": {
              "type": "string",
              "format": "binary",
              "x-ms-summary": "File Content"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "produces": [
          "application/pdf",
          "application/json"
        ]
      }
    },
    "/documents/{id}/history": {
      "get": {
        "operationId": "GetDocumentHistory",
        "summary": "A document's history",
        "description": "A document's history.",
        "x-ms-visibility": "advanced",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Document",
            "description": "The document ID (from a trigger or another action), or pick one out for signature.",
            "x-ms-dynamic-values": {
              "operationId": "ListDocuments",
              "parameters": {
                "status": {
                  "value": "in_progress"
                },
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Everything that happened to it, oldest first.",
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "x-ms-summary": "Data",
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/HistoryEntry"
                  }
                }
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/documents/{id}/remind": {
      "post": {
        "operationId": "RemindDocument",
        "summary": "Send a reminder now",
        "description": "Emails everyone still to sign (in a signing order, the one whose turn it is).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Document",
            "description": "The document ID (from a trigger or another action), or pick one out for signature.",
            "x-ms-dynamic-values": {
              "operationId": "ListDocuments",
              "parameters": {
                "status": {
                  "value": "in_progress"
                },
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Who was reminded.",
            "schema": {
              "type": "object",
              "properties": {
                "sent": {
                  "x-ms-summary": "Sent",
                  "type": "integer"
                },
                "to": {
                  "x-ms-summary": "To",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/documents/{id}/void": {
      "post": {
        "operationId": "VoidDocument",
        "summary": "Void a document",
        "description": "Stops a document that is out for signature. The people still to sign are told, with the reason.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Document",
            "description": "The document ID (from a trigger or another action), or pick one out for signature.",
            "x-ms-dynamic-values": {
              "operationId": "ListDocuments",
              "parameters": {
                "status": {
                  "value": "in_progress"
                },
                "limit": {
                  "value": 100
                }
              },
              "value-collection": "data",
              "value-path": "id",
              "value-title": "name"
            }
          },
          {
            "name": "body",
            "in": "body",
            "required": false,
            "schema": {
              "type": "object",
              "properties": {
                "reason": {
                  "x-ms-summary": "Reason",
                  "type": "string",
                  "maxLength": 500,
                  "description": "Shown to the recipients and in the history."
                },
                "notify": {
                  "x-ms-summary": "Notify",
                  "type": "boolean",
                  "default": true,
                  "description": "Email the people still to sign."
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The document, voided.",
            "schema": {
              "$ref": "#/definitions/Document"
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/events": {
      "get": {
        "operationId": "ListEvents",
        "summary": "Latest events",
        "description": "What happened to your documents lately, newest first, in the same shape webhooks deliver (for tools that poll).",
        "x-ms-visibility": "advanced",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "type": "string",
            "enum": [
              "document.sent",
              "document.viewed",
              "document.signed",
              "document.approved",
              "document.declined",
              "document.voided",
              "document.recipient_changed",
              "document.reminder_sent",
              "document.expiry_extended",
              "document.expiry_notice",
              "document.corrected",
              "document.skipped",
              "document.completed",
              "document.paper_copy"
            ],
            "x-ms-summary": "Type"
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "x-ms-summary": "Limit",
            "x-ms-visibility": "advanced"
          }
        ],
        "responses": {
          "200": {
            "description": "Events.",
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "x-ms-summary": "Data",
                  "type": "array",
                  "items": {
                    "$ref": "#/definitions/Event"
                  }
                }
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    },
    "/webhooks": {
      "post": {
        "operationId": "OnDocumentEvent",
        "summary": "When a document event happens",
        "description": "Runs the flow when something happens to a document you sent: it is sent, viewed, signed, completed, declined or voided.",
        "parameters": [
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "required": [
                "url",
                "event"
              ],
              "properties": {
                "url": {
                  "type": "string",
                  "x-ms-notification-url": true,
                  "x-ms-visibility": "internal",
                  "x-ms-summary": "Callback URL"
                },
                "event": {
                  "type": "string",
                  "x-ms-summary": "Event",
                  "description": "What starts the flow.",
                  "default": "document.completed",
                  "enum": [
                    "document.completed",
                    "document.signed",
                    "document.approved",
                    "document.viewed",
                    "document.sent",
                    "document.declined",
                    "document.voided",
                    "document.reminder_sent",
                    "document.expiry_notice"
                  ],
                  "x-ms-enum-values": [
                    {
                      "value": "document.completed",
                      "displayName": "Completed (everyone signed)"
                    },
                    {
                      "value": "document.signed",
                      "displayName": "A recipient signed"
                    },
                    {
                      "value": "document.approved",
                      "displayName": "A recipient approved"
                    },
                    {
                      "value": "document.viewed",
                      "displayName": "A recipient opened it"
                    },
                    {
                      "value": "document.sent",
                      "displayName": "Sent for signature"
                    },
                    {
                      "value": "document.declined",
                      "displayName": "Declined"
                    },
                    {
                      "value": "document.voided",
                      "displayName": "Voided by the sender"
                    },
                    {
                      "value": "document.reminder_sent",
                      "displayName": "Reminder sent"
                    },
                    {
                      "value": "document.expiry_notice",
                      "displayName": "About to expire"
                    }
                  ]
                },
                "source": {
                  "type": "string",
                  "default": "Power Automate",
                  "x-ms-visibility": "internal",
                  "x-ms-summary": "Source"
                }
              }
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Subscribed.",
            "schema": {
              "$ref": "#/definitions/Webhook"
            },
            "headers": {
              "Location": {
                "type": "string",
                "description": "Where to unsubscribe."
              }
            }
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        },
        "x-ms-trigger": "single",
        "x-ms-trigger-hint": "To see it work, send a document from bSign (or sign one).",
        "x-ms-notification-content": {
          "description": "The event",
          "schema": {
            "$ref": "#/definitions/Event"
          }
        }
      }
    },
    "/webhooks/{id}": {
      "delete": {
        "operationId": "DeleteWebhook",
        "summary": "Unsubscribe a webhook",
        "description": "Unsubscribe a webhook.",
        "x-ms-visibility": "internal",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "type": "string",
            "x-ms-summary": "Webhook",
            "description": "The webhook."
          }
        ],
        "responses": {
          "204": {
            "description": "Removed."
          },
          "default": {
            "description": "An error: { error: { code, message } }.",
            "schema": {
              "$ref": "#/definitions/Error"
            }
          }
        }
      }
    }
  },
  "definitions": {
    "Error": {
      "type": "object",
      "properties": {
        "error": {
          "x-ms-summary": "Error",
          "type": "object",
          "properties": {
            "code": {
              "x-ms-summary": "Code",
              "type": "string",
              "example": "invalid"
            },
            "message": {
              "x-ms-summary": "Message",
              "type": "string",
              "example": "Give a recipient for Client."
            },
            "details": {
              "x-ms-summary": "Details",
              "type": "object",
              "properties": {
                "problems": {
                  "x-ms-summary": "Problems",
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "Me": {
      "type": "object",
      "properties": {
        "id": {
          "x-ms-summary": "ID",
          "type": "string"
        },
        "name": {
          "x-ms-summary": "Name",
          "type": "string"
        },
        "email": {
          "x-ms-summary": "Email",
          "type": "string"
        },
        "company": {
          "x-ms-summary": "Company",
          "type": "string"
        },
        "timeZone": {
          "x-ms-summary": "Time Zone",
          "type": "string"
        },
        "site": {
          "x-ms-summary": "Site",
          "type": "object",
          "x-nullable": true,
          "properties": {
            "id": {
              "x-ms-summary": "ID",
              "type": "string"
            },
            "name": {
              "x-ms-summary": "Name",
              "type": "string"
            }
          }
        }
      }
    },
    "Role": {
      "type": "object",
      "properties": {
        "role": {
          "x-ms-summary": "Role",
          "type": "string",
          "example": "Client"
        },
        "order": {
          "x-ms-summary": "Order",
          "type": "integer",
          "description": "Place in the signing order."
        },
        "type": {
          "x-ms-summary": "Type",
          "type": "string",
          "enum": [
            "signer",
            "approver"
          ]
        },
        "inPerson": {
          "x-ms-summary": "Signs In Person",
          "type": "boolean",
          "description": "Signs in person, hosted by the sender in bSign."
        },
        "assigned": {
          "x-ms-summary": "Assigned",
          "type": "object",
          "x-nullable": true,
          "description": "Who the template names for this role (null: give one when sending).",
          "properties": {
            "name": {
              "x-ms-summary": "Name",
              "type": "string"
            },
            "email": {
              "x-ms-summary": "Email",
              "type": "string"
            }
          }
        }
      }
    },
    "Field": {
      "type": "object",
      "properties": {
        "role": {
          "x-ms-summary": "Role",
          "type": "string",
          "x-nullable": true,
          "description": "The recipient who fills it; null for fields filled before sending."
        },
        "name": {
          "x-ms-summary": "Name",
          "type": "string",
          "example": "Start date"
        },
        "type": {
          "x-ms-summary": "Type",
          "type": "string",
          "example": "date"
        },
        "required": {
          "x-ms-summary": "Required",
          "type": "boolean"
        },
        "fillable": {
          "x-ms-summary": "Fillable",
          "type": "boolean",
          "description": "Can be given a value when sending (not signatures, pictures or attachments)."
        },
        "options": {
          "x-ms-summary": "Options",
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The choices (dropdown, radio buttons, checkboxes)."
        },
        "format": {
          "x-ms-summary": "Format",
          "type": "string",
          "description": "A date field's format, e.g. MM/dd/yyyy."
        },
        "default": {
          "x-ms-summary": "Default",
          "description": "The value it has in the template."
        }
      }
    },
    "Template": {
      "type": "object",
      "properties": {
        "id": {
          "x-ms-summary": "ID",
          "type": "string"
        },
        "name": {
          "x-ms-summary": "Name",
          "type": "string"
        },
        "note": {
          "x-ms-summary": "Note",
          "type": "string"
        },
        "sendInOrder": {
          "x-ms-summary": "Send In Order",
          "type": "boolean"
        },
        "expiresInDays": {
          "x-ms-summary": "Expires In Days",
          "type": "integer"
        },
        "createdAt": {
          "x-ms-summary": "Created At",
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "x-ms-summary": "Updated At",
          "type": "string",
          "format": "date-time"
        },
        "roles": {
          "x-ms-summary": "Roles",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Role"
          }
        }
      }
    },
    "TemplateDetail": {
      "allOf": [
        {
          "$ref": "#/definitions/Template"
        },
        {
          "type": "object",
          "properties": {
            "fields": {
              "x-ms-summary": "Fields",
              "type": "array",
              "items": {
                "$ref": "#/definitions/Field"
              }
            }
          }
        }
      ]
    },
    "SendRequest": {
      "type": "object",
      "properties": {
        "name": {
          "x-ms-summary": "Name",
          "type": "string",
          "maxLength": 250,
          "description": "The document's name (default: the template's)."
        },
        "note": {
          "x-ms-summary": "Note",
          "type": "string",
          "maxLength": 200,
          "description": "A note shown to the recipients."
        },
        "reference": {
          "x-ms-summary": "Reference",
          "type": "string",
          "maxLength": 100,
          "description": "Your own reference (a quote or ticket number), shown on the document and in webhooks."
        },
        "recipients": {
          "x-ms-summary": "Recipients",
          "type": "array",
          "description": "One per role the template leaves open (others optional). Also accepted by role: {\"Client\": {\"email\": \"…\", \"name\": \"…\"}}.",
          "items": {
            "type": "object",
            "required": [
              "role",
              "email"
            ],
            "properties": {
              "role": {
                "x-ms-summary": "Role",
                "type": "string"
              },
              "name": {
                "x-ms-summary": "Name",
                "type": "string"
              },
              "email": {
                "x-ms-summary": "Email",
                "type": "string",
                "format": "email"
              }
            }
          }
        },
        "fields": {
          "x-ms-summary": "Fields",
          "type": "object",
          "additionalProperties": true,
          "description": "Values by field name, e.g. {\"Start date\": \"2026-10-01\", \"Plan\": \"Business\"}. \"<role>::<field name>\" picks one role's field. Dates in the field's format or yyyy-MM-dd; checkboxes as a list of choices; dropdowns and radio buttons as one of the choices. Empty values are left out (the template's value stays)."
        },
        "sendInOrder": {
          "x-ms-summary": "Send In Order",
          "type": "boolean",
          "description": "One after another (default: as the template says)."
        },
        "expiresInDays": {
          "x-ms-summary": "Expires In Days",
          "type": "integer",
          "minimum": 1,
          "maximum": 365
        },
        "sendEmails": {
          "x-ms-summary": "Send Emails",
          "type": "boolean",
          "default": true,
          "description": "false: bSign sends no emails, and the answer has each recipient's signing link (signingLinks) for you to share."
        }
      },
      "required": [
        "recipients"
      ]
    },
    "Recipient": {
      "type": "object",
      "properties": {
        "role": {
          "x-ms-summary": "Role",
          "type": "string"
        },
        "name": {
          "x-ms-summary": "Name",
          "type": "string"
        },
        "email": {
          "x-ms-summary": "Email",
          "type": "string"
        },
        "type": {
          "x-ms-summary": "Type",
          "type": "string",
          "enum": [
            "signer",
            "approver"
          ]
        },
        "inPerson": {
          "x-ms-summary": "Signs In Person",
          "type": "boolean"
        },
        "order": {
          "x-ms-summary": "Order",
          "type": "integer"
        },
        "status": {
          "x-ms-summary": "Status",
          "type": "string",
          "enum": [
            "draft",
            "waiting",
            "sent",
            "viewed",
            "signed",
            "approved",
            "declined",
            "skipped"
          ]
        },
        "viewedAt": {
          "x-ms-summary": "Viewed At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "completedAt": {
          "x-ms-summary": "Completed At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        }
      }
    },
    "Document": {
      "type": "object",
      "properties": {
        "id": {
          "x-ms-summary": "ID",
          "type": "string"
        },
        "name": {
          "x-ms-summary": "Name",
          "type": "string"
        },
        "reference": {
          "x-ms-summary": "Reference",
          "type": "string"
        },
        "note": {
          "x-ms-summary": "Note",
          "type": "string"
        },
        "status": {
          "x-ms-summary": "Status",
          "type": "string",
          "enum": [
            "draft",
            "in_progress",
            "completed",
            "declined",
            "voided",
            "expired"
          ]
        },
        "templateId": {
          "x-ms-summary": "Template ID",
          "type": "string",
          "x-nullable": true
        },
        "sendInOrder": {
          "x-ms-summary": "Send In Order",
          "type": "boolean"
        },
        "createdAt": {
          "x-ms-summary": "Created At",
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "x-ms-summary": "Updated At",
          "type": "string",
          "format": "date-time"
        },
        "sentAt": {
          "x-ms-summary": "Sent At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "completedAt": {
          "x-ms-summary": "Completed At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "declinedAt": {
          "x-ms-summary": "Declined At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "voidedAt": {
          "x-ms-summary": "Voided At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "declineReason": {
          "x-ms-summary": "Decline Or Void Reason",
          "type": "string"
        },
        "expiresAt": {
          "x-ms-summary": "Expires At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "recipients": {
          "x-ms-summary": "Recipients",
          "type": "array",
          "items": {
            "$ref": "#/definitions/Recipient"
          }
        },
        "files": {
          "x-ms-summary": "Files",
          "type": "object",
          "properties": {
            "pdf": {
              "x-ms-summary": "PDF Link",
              "type": "string",
              "x-nullable": true,
              "description": "Download address of the PDF (send your token)."
            },
            "certificate": {
              "x-ms-summary": "Certificate",
              "type": "string",
              "x-nullable": true,
              "description": "Download address of the certificate, once completed."
            }
          }
        },
        "signingLinks": {
          "x-ms-summary": "Signing Links",
          "type": "array",
          "description": "Only when sent with sendEmails: false.",
          "items": {
            "type": "object",
            "properties": {
              "role": {
                "x-ms-summary": "Role",
                "type": "string"
              },
              "email": {
                "x-ms-summary": "Email",
                "type": "string"
              },
              "url": {
                "x-ms-summary": "Url",
                "type": "string"
              }
            }
          }
        }
      }
    },
    "HistoryEntry": {
      "type": "object",
      "properties": {
        "event": {
          "x-ms-summary": "Event",
          "type": "string",
          "enum": [
            "document.sent",
            "document.viewed",
            "document.signed",
            "document.approved",
            "document.declined",
            "document.voided",
            "document.recipient_changed",
            "document.reminder_sent",
            "document.expiry_extended",
            "document.expiry_notice",
            "document.corrected",
            "document.skipped",
            "document.completed",
            "document.paper_copy"
          ]
        },
        "label": {
          "x-ms-summary": "Label",
          "type": "string",
          "example": "Signed"
        },
        "at": {
          "x-ms-summary": "At",
          "type": "string",
          "format": "date-time"
        },
        "actor": {
          "x-ms-summary": "Actor",
          "type": "object",
          "x-nullable": true,
          "properties": {
            "name": {
              "x-ms-summary": "Name",
              "type": "string"
            },
            "email": {
              "x-ms-summary": "Email",
              "type": "string"
            },
            "role": {
              "x-ms-summary": "Role",
              "type": "string"
            }
          }
        },
        "detail": {
          "x-ms-summary": "Detail",
          "type": "string"
        }
      }
    },
    "Event": {
      "type": "object",
      "description": "What webhooks deliver (and GET /events lists).",
      "properties": {
        "id": {
          "x-ms-summary": "ID",
          "type": "string",
          "description": "The same for every delivery of this event."
        },
        "event": {
          "x-ms-summary": "Event",
          "type": "string",
          "enum": [
            "document.sent",
            "document.viewed",
            "document.signed",
            "document.approved",
            "document.declined",
            "document.voided",
            "document.recipient_changed",
            "document.reminder_sent",
            "document.expiry_extended",
            "document.expiry_notice",
            "document.corrected",
            "document.skipped",
            "document.completed",
            "document.paper_copy"
          ]
        },
        "createdAt": {
          "x-ms-summary": "Created At",
          "type": "string",
          "format": "date-time"
        },
        "document": {
          "x-ms-summary": "Document",
          "type": "object",
          "properties": {
            "id": {
              "x-ms-summary": "ID",
              "type": "string"
            },
            "name": {
              "x-ms-summary": "Name",
              "type": "string"
            },
            "reference": {
              "x-ms-summary": "Reference",
              "type": "string"
            },
            "status": {
              "x-ms-summary": "Status",
              "type": "string",
              "enum": [
                "draft",
                "in_progress",
                "completed",
                "declined",
                "voided",
                "expired"
              ]
            }
          }
        },
        "actor": {
          "x-ms-summary": "Actor",
          "type": "object",
          "properties": {
            "name": {
              "x-ms-summary": "Name",
              "type": "string"
            },
            "email": {
              "x-ms-summary": "Email",
              "type": "string"
            },
            "role": {
              "x-ms-summary": "Role",
              "type": "string"
            }
          }
        },
        "details": {
          "x-ms-summary": "Details",
          "type": "object",
          "additionalProperties": true
        }
      }
    },
    "WebhookRequest": {
      "type": "object",
      "required": [
        "url"
      ],
      "properties": {
        "url": {
          "x-ms-summary": "Url",
          "type": "string",
          "format": "uri",
          "description": "https:// on the internet."
        },
        "events": {
          "x-ms-summary": "Events",
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "document.sent",
              "document.viewed",
              "document.signed",
              "document.approved",
              "document.declined",
              "document.voided",
              "document.recipient_changed",
              "document.reminder_sent",
              "document.expiry_extended",
              "document.expiry_notice",
              "document.corrected",
              "document.skipped",
              "document.completed",
              "document.paper_copy"
            ]
          },
          "description": "Leave out (or empty) for every event."
        },
        "event": {
          "x-ms-summary": "Event",
          "type": "string",
          "enum": [
            "document.sent",
            "document.viewed",
            "document.signed",
            "document.approved",
            "document.declined",
            "document.voided",
            "document.recipient_changed",
            "document.reminder_sent",
            "document.expiry_extended",
            "document.expiry_notice",
            "document.corrected",
            "document.skipped",
            "document.completed",
            "document.paper_copy"
          ],
          "description": "One event (the same as events: [event])."
        },
        "source": {
          "x-ms-summary": "Source",
          "type": "string",
          "maxLength": 40,
          "description": "What added it (shown in bSign), e.g. Zapier."
        }
      }
    },
    "Webhook": {
      "type": "object",
      "properties": {
        "id": {
          "x-ms-summary": "ID",
          "type": "string"
        },
        "url": {
          "x-ms-summary": "Url",
          "type": "string"
        },
        "events": {
          "x-ms-summary": "Events",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "active": {
          "x-ms-summary": "Active",
          "type": "boolean"
        },
        "secret": {
          "x-ms-summary": "Secret",
          "type": "string",
          "description": "Verifies the X-bSign-Signature header."
        },
        "source": {
          "x-ms-summary": "Source",
          "type": "string"
        },
        "lastDeliveryAt": {
          "x-ms-summary": "Last Delivery At",
          "type": "string",
          "format": "date-time",
          "x-nullable": true
        },
        "lastStatus": {
          "x-ms-summary": "Last Status",
          "type": "integer",
          "x-nullable": true
        },
        "lastError": {
          "x-ms-summary": "Last Error",
          "type": "string"
        },
        "lastEvent": {
          "x-ms-summary": "Last Event",
          "type": "string"
        },
        "createdAt": {
          "x-ms-summary": "Created At",
          "type": "string",
          "format": "date-time"
        }
      }
    }
  },
  "x-ms-connector-metadata": [
    {
      "propertyName": "Website",
      "propertyValue": "https://bsign.ca"
    },
    {
      "propertyName": "Privacy policy",
      "propertyValue": "https://bsign.ca/privacy/"
    },
    {
      "propertyName": "Categories",
      "propertyValue": "Productivity;Content and Files"
    }
  ]
}
