{
  "openapi": "3.1.0",
  "info": {
    "title": "Lumin API Reference",
    "version": "1.0.0",
    "description": "Lumin API operations. For additional endpoints, see [lumin-openapi.yaml](./lumin-openapi.yaml) in this repository."
  },
  "servers": [
    {
      "url": "https://api.luminpdf.com/v1",
      "description": "Production server"
    },
    {
      "url": "https://api-sandbox.luminpdf.com/v1",
      "description": "Sandbox server"
    }
  ],
  "tags": [
    {
      "name": "Agreements",
      "description": "Everything about Agreements"
    },
    {
      "name": "Signature Requests",
      "description": "Everything about Signature Requests"
    }
  ],
  "paths": {
    "/agreements": {
      "post": {
        "summary": "Create Agreement",
        "description": "Create a new AgreementGen document from a AgreementGen template.",
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "tags": [
          "Agreements"
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AgreementCreateRequest"
              },
              "example": {
                "method": "template",
                "agreement_name": "NDA Agreement",
                "agreement_data": {
                  "template_id": "ag_12312321",
                  "fields": {
                    "Client.Name": "Acme Corp",
                    "Document.EffectiveDate": "2025-08-01"
                  },
                  "variables": {
                    "Client.Name": "Acme Corp",
                    "Document.EffectiveDate": "2025-08-01"
                  },
                  "linked_objects": [
                    {
                      "integration": "salesforce",
                      "entity_type": "opportunity",
                      "record_id": "0065g00000Vh123ABC",
                      "reference_url": "https://lumin-uat-dev-ed.develop.lightning.force.com/lightning/r/Account/001QE00000eDhhjYAC/view"
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Returns the information of the created AgreementGen document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AgreementSummary"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/agreements/{agreement_id}/file": {
      "get": {
        "summary": "Get Agreement File",
        "description": "Obtain a downloadable file or binary PDF data from an AgreementGen document.",
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "tags": [
          "Agreements"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "agreement_id",
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "ID of the AgreementGen document."
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the downloadable file or binary PDF data of the AgreementGen document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "signed_url": {
                      "type": "string",
                      "format": "uri",
                      "description": "Signed HTTPS URL to download the agreement file. Expires in 30 minutes."
                    },
                    "expires_at": {
                      "type": "integer",
                      "format": "unix-epoch",
                      "description": "Unix epoch timestamp (in seconds) indicating when `signed_url` will no longer work."
                    }
                  }
                },
                "example": {
                  "signed_url": "https://files.luminpdf.com/download/agreement-abc123.pdf?expires=2025-08-24T10:45:00Z",
                  "expires_at": 1766726700000
                }
              },
              "application/pdf": {
                "schema": {
                  "type": "string",
                  "format": "binary",
                  "description": "Binary PDF data."
                }
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/signature_request/cancel/{signature_request_id}": {
      "put": {
        "summary": "Cancel Signature Request",
        "description": "Cancel a signature request.",
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "tags": [
          "Signature Requests"
        ],
        "parameters": [
          {
            "in": "path",
            "name": "signature_request_id",
            "schema": {
              "type": "string"
            },
            "required": true,
            "description": "ID of the signature request."
          }
        ],
        "responses": {
          "200": {
            "description": "Returns the information of the cancelled signature request.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "signature_request_id": {
                      "type": "string",
                      "description": "The unique identifier for the signature request."
                    },
                    "status": {
                      "type": "string",
                      "description": "The status of the signature request.",
                      "enum": [
                        "CANCELLED"
                      ]
                    }
                  }
                }
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LinkedObject": {
        "type": "object",
        "title": "LinkedObject",
        "properties": {
          "integration": {
            "type": "string",
            "description": "The external system or integration where the linked object lives. Example: `salesforce`, `hubspot`."
          },
          "entity_type": {
            "type": "string",
            "description": "The type of the linked object in that provider's data model. Example: `opportunity`, `contact`, `deal`."
          },
          "record_id": {
            "type": "string",
            "description": "The unique identifier of the linked object in the provider system. Example: `0065g00000Vh123ABC` (Salesforce record ID)."
          },
          "reference_url": {
            "type": "string",
            "format": "uri",
            "description": "The reference URL of the linked object in the provider system."
          }
        }
      },
      "AgreementTemplateData": {
        "type": "object",
        "title": "AgreementTemplateData",
        "required": [
          "template_id"
        ],
        "properties": {
          "template_id": {
            "type": "string",
            "description": "Unique identifier of the AG template. Obtainable from the template list API."
          },
          "variables": {
            "type": "object",
            "description": "Key-value map of Variables in the template. Pass values for the variables to render them into the created document or leave values blank to make them available for insertion later."
          },
          "fields": {
            "type": "object",
            "description": "Key-value pairs for Form Fields defined in the template. Keys must match field names. Values prefill the corresponding form fields in the generated document. Currently supports: `text` and `checkbox` fields."
          },
          "linked_objects": {
            "type": "array",
            "description": "CRM or external objects linked to the agreement.",
            "items": {
              "$ref": "#/components/schemas/LinkedObject"
            }
          }
        }
      },
      "AgreementCreateRequest": {
        "type": "object",
        "title": "AgreementCreateRequest",
        "required": [
          "method",
          "agreement_data"
        ],
        "properties": {
          "method": {
            "type": "string",
            "enum": [
              "template"
            ],
            "description": "Must be set to `template`."
          },
          "agreement_name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "Human-friendly title of the agreement (1-255 chars). Defaults to input name or \"New document\" if not provided in the request body."
          },
          "agreement_data": {
            "$ref": "#/components/schemas/AgreementTemplateData"
          }
        }
      },
      "AgreementSummary": {
        "type": "object",
        "title": "AgreementSummary",
        "required": [
          "id",
          "name",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The unique identifier for the agreement."
          },
          "name": {
            "type": "string",
            "description": "The name of the agreement."
          },
          "preview_url": {
            "type": "string",
            "format": "uri",
            "description": "The URL to preview the agreement in the browser."
          },
          "created_at": {
            "type": "integer",
            "format": "unix-epoch",
            "description": "The time the agreement was created (Unix timestamp in milliseconds)."
          },
          "linked_objects": {
            "type": "array",
            "description": "CRM or external objects linked to the agreement.",
            "items": {
              "$ref": "#/components/schemas/LinkedObject"
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "title": "Error",
        "required": [
          "error_code",
          "error_message"
        ],
        "properties": {
          "error_code": {
            "type": "string",
            "description": "The system error code."
          },
          "error_message": {
            "type": "string",
            "description": "The human-readable error message."
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Provide your API key in the `Authorization` header, e.g., `Authorization: API-key`."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Provide your token in the `Authorization` header, e.g., `Authorization: Bearer JWT`."
      }
    }
  }
}