{
  "openapi": "3.0.4",
  "info": {
    "title": "DealBuilder API",
    "description": "API for DealBuilder application",
    "version": "1.0"
  },
  "paths": {
    "/v1/Documents": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Creates a new document",
        "requestBody": {
          "description": "The document creation request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocumentRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentResponseApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Lists all documents with optional filtering and sorting",
        "parameters": [
          {
            "name": "CreatedAfter",
            "in": "query",
            "description": "Filter documents created after this date",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "CreatedBefore",
            "in": "query",
            "description": "Filter documents created before this date",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "UpdatedAfter",
            "in": "query",
            "description": "Filter documents last updated on or after this date and time (UTC).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "AcceptedAfter",
            "in": "query",
            "description": "Filter documents accepted on or after this date.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "AcceptedBefore",
            "in": "query",
            "description": "Filter documents accepted on or before this date.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "Status",
            "in": "query",
            "description": "Filter documents by status",
            "schema": {
              "$ref": "#/components/schemas/DocumentStatus"
            }
          },
          {
            "name": "DocumentNumber",
            "in": "query",
            "description": "Exact document number. Matches accepted documents only.",
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          },
          {
            "name": "Search",
            "in": "query",
            "description": "Free-text search on title and party name, company name, email, and organisation number. Accepted documents also match document number. Case-insensitive substring. Combines with the other filters.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Page",
            "in": "query",
            "description": "Page number (1-based)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "description": "Number of items per page. Set to -1 for all items. Max number of items returned is 1000",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "SortBy",
            "in": "query",
            "description": "Sort by createdDate or acceptedDate. Omit for the default order: newest created date. With no status filter, pending documents are returned first, then accepted documents, and this sorts within each group. acceptedDate requires a query that returns accepted documents only.",
            "schema": {
              "$ref": "#/components/schemas/DocumentSortField"
            }
          },
          {
            "name": "SortDirection",
            "in": "query",
            "description": "asc or desc. Defaults to desc. When SortBy is omitted, applies to createdDate.",
            "schema": {
              "$ref": "#/components/schemas/DocumentSortDirection"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentResponsePagedResponseApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/Documents/{id}": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Retrieves a document by its ID, including its event history.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The document ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentResponseApiResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Documents"
        ],
        "summary": "Partially updates an existing document",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The document ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The update request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateDocumentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateDocumentResponseApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/Documents/{id}/send": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Sends a document that was stored as a draft. Only documents with draft status can be sent.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The document ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "How the document should be sent",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendDocumentRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SendDocumentRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SendDocumentRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentResponseApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/Documents/{id}/send-reminder": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Sends a reminder for a document to a specific party",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The document ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "description": "The reminder request",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendReminderRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SendReminderRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SendReminderRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendReminderResponseApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/Products/{id}": {
      "put": {
        "tags": [
          "Products"
        ],
        "summary": "Updates an existing product by DealBuilder ID or External ID, or creates one if it doesn't exist.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "DealBuilder product ID or your External ID (see idType)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idType",
            "in": "query",
            "description": "Specifies whether the id is a dealbuilder ID or your external ID",
            "schema": {
              "$ref": "#/components/schemas/IdType"
            }
          }
        ],
        "requestBody": {
          "description": "The product details to create or update",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertProductRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertProductRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertProductRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponseApiResponse"
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponseApiResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      },
      "patch": {
        "tags": [
          "Products"
        ],
        "summary": "Partially updates an existing product by DealBuilder ID or External ID.\r\nOnly the provided fields will be updated.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "DealBuilder product ID or your External ID (see idType)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idType",
            "in": "query",
            "description": "Specifies whether the id is a dealbuilder ID or your external ID",
            "schema": {
              "$ref": "#/components/schemas/IdType"
            }
          }
        ],
        "requestBody": {
          "description": "The product fields to update",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertProductRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertProductRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UpsertProductRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponseApiResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Products"
        ],
        "summary": "Retrieves a product by its ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "description": "The product ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "idType",
            "in": "query",
            "description": "Specifies whether the id is a dealbuilder ID or your external ID",
            "schema": {
              "$ref": "#/components/schemas/IdType"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponseApiResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/Products": {
      "get": {
        "tags": [
          "Products"
        ],
        "summary": "Lists all products with optional filtering",
        "parameters": [
          {
            "name": "IsActive",
            "in": "query",
            "description": "Filter products by active state",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "Page",
            "in": "query",
            "description": "Page number (1-based)",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "PageSize",
            "in": "query",
            "description": "Number of items per page. Set to -1 for all items. Max number of items returned is 1000",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductResponseIEnumerableApiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/uploads": {
      "post": {
        "tags": [
          "Upload"
        ],
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  }
                }
              },
              "encoding": {
                "files": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/FileUploadResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileUploadResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileUploadResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AddressDto": {
        "type": "object",
        "properties": {
          "streetAddress": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The street address",
            "nullable": true
          },
          "city": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The city",
            "nullable": true
          },
          "zip": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The postal/zip code",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ApiErrorResponse": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "traceId": {
            "type": "string",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "API error response for validation and business logic errors"
      },
      "CreateDocumentOrderLineDto": {
        "required": [
          "productOrBundleId"
        ],
        "type": "object",
        "properties": {
          "productOrBundleId": {
            "minLength": 1,
            "type": "string",
            "description": "The product ID"
          },
          "name": {
            "type": "string",
            "description": "The name of the product or bundle. If not set, the name from the product or bundle will be used. If name is locked this cannot be set.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "/// The description of the product or bundle. If not set, the description from the product or bundle will be used. If description is locked this cannot be set.",
            "nullable": true
          },
          "value": {
            "type": "number",
            "description": "The unit price.",
            "format": "double",
            "nullable": true
          },
          "discount": {
            "type": "number",
            "description": "The discount amount entered as percentage or an absolute value",
            "format": "double",
            "nullable": true
          },
          "discountInPercentage": {
            "type": "boolean",
            "description": "Whether the discount is a percentage"
          },
          "quantity": {
            "type": "integer",
            "description": "The quantity",
            "format": "int32"
          },
          "subOrderLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateDocumentOrderLineDto"
            },
            "description": "The sub-order lines (for bundles)",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents an order line in the contract"
      },
      "CreateDocumentRequest": {
        "required": [
          "creatorEmail",
          "mode",
          "senderEmail",
          "templateId",
          "title",
          "validUntil"
        ],
        "type": "object",
        "properties": {
          "mode": {
            "$ref": "#/components/schemas/DocumentCreationMode"
          },
          "uploadedPdfUrl": {
            "type": "string",
            "description": "This can be set if the document type is set to Uploaded PDF in the template. The url can be created by first calling the upload end point in the api.",
            "nullable": true
          },
          "title": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string"
          },
          "description": {
            "maxLength": 2000,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "terms": {
            "maxLength": 2000,
            "minLength": 0,
            "type": "string",
            "nullable": true
          },
          "validUntil": {
            "type": "string",
            "format": "date-time"
          },
          "orderLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CreateDocumentOrderLineDto"
            },
            "nullable": true
          },
          "templateId": {
            "minLength": 1,
            "type": "string"
          },
          "creatorEmail": {
            "minLength": 1,
            "type": "string"
          },
          "senderEmail": {
            "minLength": 1,
            "type": "string"
          },
          "internalSignatoryEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "copyEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Email addresses that will receive a read only copy of the document when the document is sent.\r\nThese addresses are not visible to the signing parties.",
            "nullable": true
          },
          "externalSignatories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ExternalSignatoryDto"
            },
            "nullable": true
          },
          "customFieldValues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentCustomFieldValueDto"
            },
            "nullable": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentAttachmentDto"
            },
            "description": "A list of attachment name and  url pairs. The urls should be DealBuilder urls. \r\nAll attachments that are locked in the template will always be part of the generated document. \r\nIf this property is not set the default attachments from the template will be used.\r\nIf this property is set its attachments will replace the non-locked attachments from the template.",
            "nullable": true
          },
          "coolingOffPeriodInHours": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for creating a new contract"
      },
      "CustomFieldType": {
        "enum": [
          "Number",
          "OpenText",
          "DateField",
          "DropDown",
          "Formula"
        ],
        "type": "string",
        "description": "The data type of a custom field value on a document."
      },
      "DistributionType": {
        "enum": [
          "Email",
          "Sms",
          "EmailAndSms",
          "Manual"
        ],
        "type": "string",
        "description": "How a document or reminder is delivered."
      },
      "DocumentAttachmentDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the attachment in the document",
            "nullable": true
          },
          "url": {
            "type": "string",
            "description": "The url of the attachment. This should be a dealbuilder url.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DocumentCreationMode": {
        "enum": [
          "StoreAsDraft",
          "SendByEmail",
          "SendBySms",
          "SendByEmailAndSms",
          "SendManually"
        ],
        "type": "string"
      },
      "DocumentCustomFieldValueDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The id of the custom field as defined on the template.",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The label of the custom field as defined on the template. Omitted on create; populated when reading a document.",
            "nullable": true
          },
          "type": {
            "$ref": "#/components/schemas/CustomFieldType"
          },
          "value": {
            "type": "string",
            "description": "The value set on this document.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A custom field value on a document. On create, send DealBuilder.Api.Models.Documents.DocumentCustomFieldValueDto.Id and DealBuilder.Api.Models.Documents.DocumentCustomFieldValueDto.Value.\r\nResponses also include the field label and type so the value can be interpreted without looking up the template."
      },
      "DocumentDeliveryChannel": {
        "enum": [
          "Email",
          "SMS",
          "InPerson",
          "InApp"
        ],
        "type": "string"
      },
      "DocumentEventDto": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/DocumentEventType"
          },
          "occurredAt": {
            "type": "string",
            "description": "UTC timestamp when the event occurred.",
            "format": "date-time"
          },
          "actor": {
            "type": "string",
            "description": "Email address or phone number of the party associated with the event.",
            "nullable": true
          },
          "ip": {
            "type": "string",
            "description": "IP address recorded for the event, when available.",
            "nullable": true
          },
          "userAgent": {
            "type": "string",
            "description": "Browser or client user-agent string recorded for the event, when available.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "A timestamped record of something that happened on a document, such as sending, delivery, opening, or acceptance."
      },
      "DocumentEventType": {
        "enum": [
          "DocumentSentViaEmail",
          "DocumentSentViaSms",
          "EmailDeferred",
          "EmailBounced",
          "EmailDropped",
          "EmailProcessed",
          "DocumentDeliveredViaEmail",
          "DocumentDeliveredViaSms",
          "DocumentOpenedViaEmail",
          "DocumentOpenedViaSms",
          "DocumentOpenedAfterExpiryDate",
          "DocumentOpenedAfterRevocation",
          "DocumentAcceptedViaEmail",
          "DocumentAcceptedViaSms",
          "DocumentAcceptedInPerson",
          "DocumentAcceptedOnSend",
          "DocumentAcceptedByAdmin",
          "DocumentAcceptedAfterExpiryDate",
          "DocumentRevoked",
          "WebhookSent",
          "UserOptedOut",
          "UserOptedIn"
        ],
        "type": "string",
        "description": "The type of event recorded on a document."
      },
      "DocumentOrderLineDto": {
        "type": "object",
        "properties": {
          "productId": {
            "type": "string",
            "description": "The DealBuilder product ID",
            "nullable": true
          },
          "productExternalId": {
            "type": "string",
            "description": "The external product ID. This is the id of the product in a system that communicats with DealBuilder via the API.",
            "nullable": true
          },
          "name": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The product name",
            "nullable": true
          },
          "description": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The product description",
            "nullable": true
          },
          "productInternalDescription": {
            "type": "string",
            "description": "The product's internal description",
            "nullable": true
          },
          "tax": {
            "type": "number",
            "description": "The tax rate",
            "format": "double"
          },
          "value": {
            "type": "number",
            "description": "The unit price (if null, seller must enter value when contract is created)",
            "format": "double",
            "nullable": true
          },
          "taxValue": {
            "type": "number",
            "description": "The tax amount",
            "format": "double"
          },
          "discount": {
            "type": "number",
            "description": "The discount amount",
            "format": "double"
          },
          "discountInPercentage": {
            "type": "boolean",
            "description": "Whether the discount is a percentage"
          },
          "afterDiscount": {
            "type": "number",
            "description": "The price after discount",
            "format": "double"
          },
          "recurring": {
            "type": "boolean",
            "description": "Whether this is a recurring charge"
          },
          "quantity": {
            "maximum": 2147483647,
            "minimum": 1,
            "type": "integer",
            "description": "The quantity",
            "format": "int32"
          },
          "cost": {
            "type": "number",
            "description": "The cost",
            "format": "double"
          },
          "baseCost": {
            "type": "number",
            "description": "The base cost",
            "format": "double"
          },
          "hasPrice": {
            "type": "boolean",
            "description": "Whether this product has a price"
          },
          "hasCost": {
            "type": "boolean",
            "description": "Whether this product has a cost"
          },
          "hidePrice": {
            "type": "boolean",
            "description": "Whether to hide the price in the contract"
          },
          "hasDiscount": {
            "type": "boolean",
            "description": "Whether this product has a discount"
          },
          "isBundle": {
            "type": "boolean",
            "description": "Whether this is a bundle"
          },
          "subOrderLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentOrderLineDto"
            },
            "description": "The sub-order lines (for bundles)",
            "nullable": true
          },
          "lock": {
            "type": "boolean",
            "description": "Whether this line is locked (user can't delete it)"
          }
        },
        "additionalProperties": false,
        "description": "Represents an order line in the contract"
      },
      "DocumentPartyDto": {
        "required": [
          "email",
          "name",
          "roles"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier for the party",
            "nullable": true
          },
          "roles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentPartyRole"
            },
            "description": "The roles this party has in the contract (e.g., Creator, Sender, Signatory)"
          },
          "title": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The party's title or position",
            "nullable": true
          },
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The party's full name (used when FirstName/LastName are not available)"
          },
          "firstName": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The party's first name",
            "nullable": true
          },
          "lastName": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The party's last name",
            "nullable": true
          },
          "email": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The party's email address",
            "format": "email"
          },
          "phoneNumber": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The party's phone number",
            "format": "tel",
            "nullable": true
          },
          "profilePicture": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "URL to the party's profile picture",
            "format": "uri",
            "nullable": true
          },
          "companyName": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The party's company name",
            "nullable": true
          },
          "companyOrgNumber": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The party's company organization number",
            "nullable": true
          },
          "address": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The party's address as a formatted string",
            "nullable": true
          },
          "visitAddress": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The party's visit address as a formatted string",
            "nullable": true
          },
          "detailedAddress": {
            "$ref": "#/components/schemas/AddressDto"
          },
          "detailedVisitAddress": {
            "$ref": "#/components/schemas/AddressDto"
          },
          "webPage": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The party's company website",
            "format": "uri",
            "nullable": true
          },
          "acceptedSigningType": {
            "$ref": "#/components/schemas/DocumentSigningType"
          },
          "acceptedDeliveryType": {
            "$ref": "#/components/schemas/DocumentDeliveryChannel"
          },
          "signatureImage": {
            "type": "string",
            "description": "The party's signature image (base64 encoded)",
            "nullable": true
          },
          "signingUrl": {
            "type": "string",
            "description": "Personal signing link for this party. Populated for signatories\r\n(internal or external) that have not yet signed and that belong to a\r\ndocument which has been activated/sent. Will be null for the sender,\r\nthe creator, parties that have already accepted (e.g. an internal\r\nsignatory auto-signed at send), and for documents still in draft.",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Represents a party involved in the contract"
      },
      "DocumentPartyRole": {
        "enum": [
          "Creator",
          "Sender",
          "Approver",
          "InternalSignatory",
          "ExternalSignatory"
        ],
        "type": "string"
      },
      "DocumentResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "terms": {
            "type": "string",
            "nullable": true
          },
          "createdDate": {
            "type": "string",
            "format": "date-time"
          },
          "acceptedDate": {
            "type": "string",
            "description": "Date and time the document was fully accepted. Null when the document has not been accepted.",
            "format": "date-time",
            "nullable": true
          },
          "updatedDate": {
            "type": "string",
            "description": "Date and time the document was last updated (UTC). Same instant used by UpdatedAfter. Precision is one second.",
            "format": "date-time"
          },
          "expiryDate": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "$ref": "#/components/schemas/DocumentStatus"
          },
          "parties": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentPartyDto"
            },
            "nullable": true
          },
          "orderLines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentOrderLineDto"
            },
            "nullable": true
          },
          "uploadedDocumentUrl": {
            "type": "string",
            "nullable": true
          },
          "appUrl": {
            "type": "string",
            "nullable": true
          },
          "previewUrl": {
            "type": "string",
            "nullable": true
          },
          "documentNumber": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          },
          "pdfUrl": {
            "type": "string",
            "nullable": true
          },
          "customFieldValues": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentCustomFieldValueDto"
            },
            "description": "Custom field values set on this document. Empty when the document has none.\r\nThese are the filled-in values, not the template field definitions.",
            "nullable": true
          },
          "copyEmails": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Email addresses that receive a silent copy of the document email when the document is sent.\r\nThese addresses are not visible to the signing parties.",
            "nullable": true
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentEventDto"
            },
            "description": "Chronological audit trail for the document. Populated when retrieving a single document by ID; omitted from list responses.",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DocumentResponseApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/DocumentResponse"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Generic API response wrapper for consistent response format"
      },
      "DocumentResponsePagedResponse": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentResponse"
            },
            "nullable": true
          },
          "totalItems": {
            "type": "integer",
            "format": "int32"
          },
          "page": {
            "type": "integer",
            "format": "int32"
          },
          "pageSize": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "DocumentResponsePagedResponseApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/DocumentResponsePagedResponse"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Generic API response wrapper for consistent response format"
      },
      "DocumentSigningType": {
        "enum": [
          "Click",
          "ElectronicId",
          "Signature"
        ],
        "type": "string"
      },
      "DocumentSortDirection": {
        "enum": [
          "Asc",
          "Desc"
        ],
        "type": "string"
      },
      "DocumentSortField": {
        "enum": [
          "CreatedDate",
          "AcceptedDate"
        ],
        "type": "string"
      },
      "DocumentStatus": {
        "enum": [
          "Draft",
          "Sent",
          "Revoked",
          "Accepted",
          "PendingApproval"
        ],
        "type": "string"
      },
      "ExternalSignatoryDto": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The party's full name (used when FirstName/LastName are not available)",
            "nullable": true
          },
          "firstName": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The party's first name",
            "nullable": true
          },
          "lastName": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The party's last name",
            "nullable": true
          },
          "email": {
            "maxLength": 100,
            "minLength": 0,
            "type": "string",
            "description": "The party's email address",
            "format": "email"
          },
          "phoneNumber": {
            "maxLength": 20,
            "minLength": 0,
            "type": "string",
            "description": "The party's phone number",
            "format": "tel",
            "nullable": true
          },
          "companyName": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The party's company name",
            "nullable": true
          },
          "companyOrgNumber": {
            "maxLength": 50,
            "minLength": 0,
            "type": "string",
            "description": "The party's company organization number",
            "nullable": true
          },
          "address": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The party's address as a formatted string",
            "nullable": true
          },
          "visitAddress": {
            "maxLength": 500,
            "minLength": 0,
            "type": "string",
            "description": "The party's visit address as a formatted string",
            "nullable": true
          },
          "detailedAddress": {
            "$ref": "#/components/schemas/AddressDto"
          },
          "detailedVisitAddress": {
            "$ref": "#/components/schemas/AddressDto"
          }
        },
        "additionalProperties": false,
        "description": "Represents a party involved in the contract"
      },
      "FileUploadResponse": {
        "type": "object",
        "properties": {
          "fileUrls": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "IdType": {
        "enum": [
          "DealBuilder",
          "External"
        ],
        "type": "string"
      },
      "ProductResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The product ID",
            "nullable": true
          },
          "externalId": {
            "type": "string",
            "description": "The external product ID. This is the id of the product in a system that communicates with DealBuilder via the API.",
            "nullable": true
          },
          "organizationId": {
            "type": "string",
            "description": "The organization ID this product belongs to",
            "nullable": true
          },
          "companyId": {
            "type": "string",
            "description": "The company ID this product belongs to",
            "nullable": true
          },
          "name": {
            "type": "string",
            "description": "The product name",
            "nullable": true
          },
          "internalName": {
            "type": "string",
            "description": "The product's internal name",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether the product is active"
          },
          "descriptionShort": {
            "type": "string",
            "description": "The short description of the product",
            "nullable": true
          },
          "description": {
            "type": "string",
            "description": "The full description of the product",
            "nullable": true
          },
          "tax": {
            "type": "number",
            "description": "The tax rate",
            "format": "double"
          },
          "value": {
            "type": "number",
            "description": "The unit price (if null, seller must enter value when contract is created)",
            "format": "double",
            "nullable": true
          },
          "minValue": {
            "type": "number",
            "description": "The lowest price that this product can be sold for",
            "format": "double"
          },
          "maxDiscount": {
            "type": "number",
            "description": "The maximum discount percentage",
            "format": "double"
          },
          "cost": {
            "type": "number",
            "description": "The cost of the product",
            "format": "double"
          },
          "isCostInPercentage": {
            "type": "boolean",
            "description": "Whether the cost is specified as a percentage"
          },
          "lockValue": {
            "type": "boolean",
            "description": "Whether the price is locked"
          },
          "lockDiscount": {
            "type": "boolean",
            "description": "Whether the discount is locked"
          },
          "lockDescription": {
            "type": "boolean",
            "description": "Whether the description is locked"
          },
          "lockDescriptionShort": {
            "type": "boolean",
            "description": "Whether the short description is locked"
          },
          "lockName": {
            "type": "boolean",
            "description": "Whether the name is locked"
          },
          "recurring": {
            "type": "boolean",
            "description": "Whether this is a recurring charge"
          },
          "lockCost": {
            "type": "boolean",
            "description": "Whether the cost is locked"
          },
          "hasPrice": {
            "type": "boolean",
            "description": "Whether this product has a price"
          },
          "hidePrice": {
            "type": "boolean",
            "description": "Whether to hide the price in the contract"
          },
          "hasDiscount": {
            "type": "boolean",
            "description": "Whether this product has a discount"
          },
          "hasCost": {
            "type": "boolean",
            "description": "Whether this product has a cost"
          },
          "onlyAsPartOfBundle": {
            "type": "boolean",
            "description": "Whether this product can only be used as part of a bundle"
          },
          "created": {
            "type": "string",
            "description": "When the product was created",
            "format": "date-time"
          },
          "lastModified": {
            "type": "string",
            "description": "When the product was last modified",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for product operations"
      },
      "ProductResponseApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/ProductResponse"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Generic API response wrapper for consistent response format"
      },
      "ProductResponseIEnumerableApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProductResponse"
            },
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Generic API response wrapper for consistent response format"
      },
      "SendDocumentRequest": {
        "required": [
          "distributionType"
        ],
        "type": "object",
        "properties": {
          "distributionType": {
            "$ref": "#/components/schemas/DistributionType"
          }
        },
        "additionalProperties": false,
        "description": "Request model for sending a draft document"
      },
      "SendReminderRequest": {
        "required": [
          "distributionType",
          "partyId"
        ],
        "type": "object",
        "properties": {
          "partyId": {
            "minLength": 1,
            "type": "string",
            "description": "The ID of the party to send the reminder to"
          },
          "distributionType": {
            "$ref": "#/components/schemas/DistributionType"
          }
        },
        "additionalProperties": false,
        "description": "Request model for sending a reminder to a document party"
      },
      "SendReminderResponse": {
        "type": "object",
        "properties": {
          "documentId": {
            "type": "string",
            "description": "The ID of the document the reminder was sent for",
            "nullable": true
          },
          "partyId": {
            "type": "string",
            "description": "The ID of the party the reminder was sent to",
            "nullable": true
          },
          "distributionType": {
            "$ref": "#/components/schemas/DistributionType"
          },
          "sentAt": {
            "type": "string",
            "description": "When the reminder was sent",
            "format": "date-time"
          },
          "message": {
            "type": "string",
            "description": "Additional message about the reminder",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for sending a reminder to a document party"
      },
      "SendReminderResponseApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/SendReminderResponse"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Generic API response wrapper for consistent response format"
      },
      "UpdateDocumentRequest": {
        "type": "object",
        "properties": {
          "status": {
            "$ref": "#/components/schemas/UpdateDocumentStatus"
          },
          "validUntil": {
            "type": "string",
            "description": "The new valid until date for the document",
            "format": "date-time",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for updating a document"
      },
      "UpdateDocumentResponse": {
        "type": "object",
        "properties": {
          "documentId": {
            "type": "string",
            "description": "The document ID that was updated",
            "nullable": true
          },
          "status": {
            "type": "string",
            "description": "The updated status if it was changed",
            "nullable": true
          },
          "validUntil": {
            "type": "string",
            "description": "The updated valid until date if it was changed",
            "format": "date-time",
            "nullable": true
          },
          "updatedAt": {
            "type": "string",
            "description": "When the update was performed",
            "format": "date-time"
          },
          "message": {
            "type": "string",
            "description": "Message describing what was updated",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Response model for updating a document"
      },
      "UpdateDocumentResponseApiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "$ref": "#/components/schemas/UpdateDocumentResponse"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false,
        "description": "Generic API response wrapper for consistent response format"
      },
      "UpdateDocumentStatus": {
        "enum": [
          "Revoked"
        ],
        "type": "string"
      },
      "UpsertProductRequest": {
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The product name",
            "nullable": true
          },
          "internalName": {
            "type": "string",
            "description": "The product's internal name",
            "nullable": true
          },
          "active": {
            "type": "boolean",
            "description": "Whether the product is active",
            "nullable": true
          },
          "shortDescription": {
            "maxLength": 200,
            "minLength": 0,
            "type": "string",
            "description": "The short description of the product",
            "nullable": true
          },
          "internalDescription": {
            "maxLength": 2000,
            "minLength": 0,
            "type": "string",
            "description": "The full description of the product",
            "nullable": true
          },
          "tax": {
            "maximum": 100,
            "minimum": 0,
            "type": "number",
            "description": "The tax rate",
            "format": "double",
            "nullable": true
          },
          "value": {
            "maximum": 1.7976931348623157E+308,
            "minimum": 0,
            "type": "number",
            "description": "The unit price (if null, seller must enter value when contract is created)",
            "format": "double",
            "nullable": true
          },
          "minValue": {
            "maximum": 1.7976931348623157E+308,
            "minimum": 0,
            "type": "number",
            "description": "The lowest price that this product can be sold for",
            "format": "double",
            "nullable": true
          },
          "maxDiscount": {
            "maximum": 100,
            "minimum": 0,
            "type": "number",
            "description": "The maximum discount percentage",
            "format": "double",
            "nullable": true
          },
          "cost": {
            "maximum": 1.7976931348623157E+308,
            "minimum": 0,
            "type": "number",
            "description": "The cost of the product",
            "format": "double",
            "nullable": true
          },
          "isCostInPercentage": {
            "type": "boolean",
            "description": "Whether the cost is specified as a percentage",
            "nullable": true
          },
          "lockValue": {
            "type": "boolean",
            "description": "Whether the price is locked",
            "nullable": true
          },
          "lockDiscount": {
            "type": "boolean",
            "description": "Whether the discount is locked",
            "nullable": true
          },
          "lockDescription": {
            "type": "boolean",
            "description": "Whether the description is locked",
            "nullable": true
          },
          "lockDescriptionShort": {
            "type": "boolean",
            "description": "Whether the short description is locked",
            "nullable": true
          },
          "lockName": {
            "type": "boolean",
            "description": "Whether the name is locked",
            "nullable": true
          },
          "recurring": {
            "type": "boolean",
            "description": "Whether this is a recurring charge",
            "nullable": true
          },
          "lockCost": {
            "type": "boolean",
            "description": "Whether the cost is locked",
            "nullable": true
          },
          "hasPrice": {
            "type": "boolean",
            "description": "Whether this product has a price",
            "nullable": true
          },
          "hidePrice": {
            "type": "boolean",
            "description": "Whether to hide the price in the contract",
            "nullable": true
          },
          "hasDiscount": {
            "type": "boolean",
            "description": "Whether this product has a discount",
            "nullable": true
          },
          "hasCost": {
            "type": "boolean",
            "description": "Whether this product has a cost",
            "nullable": true
          },
          "onlyAsPartOfBundle": {
            "type": "boolean",
            "description": "Whether this product can only be used as part of a bundle",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Request model for creating or updating a product"
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "API Key authentication",
        "name": "X-API-Key",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ]
    }
  ],
  "tags": [
    {
      "name": "Documents"
    },
    {
      "name": "Products"
    },
    {
      "name": "Upload"
    }
  ]
}