{
  "openapi": "3.1.0",
  "info": {
    "title": "Aloan Commercial API",
    "version": "v1",
    "description": "Create relationships and deals, send documents in, and read the analysis back out."
  },
  "servers": [
    {
      "url": "https://api-sandbox.aloan.ai/api/v1",
      "description": "Sandbox: test data, production behaviour."
    },
    {
      "url": "https://api.aloan.ai/api/v1",
      "description": "Production: live borrower data."
    }
  ],
  "tags": [
    {
      "name": "me",
      "x-displayName": "Your key",
      "description": "The first call to make with a new key: it proves the key works and says what it is."
    },
    {
      "name": "reference",
      "x-displayName": "Reference lists",
      "description": "The vocabularies you need before you write: who can own a deal, which loan types your organization has, and what a data type can be. Small tables, returned whole."
    },
    {
      "name": "relationships",
      "x-displayName": "Relationships",
      "description": "Create and maintain the borrowing relationship a deal will hang off."
    },
    {
      "name": "uploads",
      "x-displayName": "Uploads",
      "description": "One way to get a file into Aloan, used everywhere a file is wanted. Declare it, put the bytes straight into our storage, then reference the upload id — that reference is what tells us the file has landed, and we verify it against storage before doing anything with it."
    },
    {
      "name": "deals",
      "x-displayName": "Deals",
      "description": "Create a deal from a structured payload when you hold the terms, or from a term sheet when you hold the document."
    },
    {
      "name": "documents",
      "x-displayName": "Documents and files",
      "description": "Put borrower documents on a deal. Upload the bytes first, then file the uploads here; every file gets an id the moment we accept it and moves through `queued` → `classifying` → `processing` → `filed`, or to `awaiting_review`, `duplicate`, `failed` or `dismissed`. Say where a file belongs when you know, and it goes there: placement beats matching, and the more you say, the less we guess. A file you place on an entity never raises an identity question, so a package filed with entity ids rarely needs anyone in the app. Placement never silences a concern: when the document disagrees with what you said (you placed it as 2024, it reads as 2025), the placement stands and the file carries a `period_mismatch` or `type_mismatch` concern your team sees in the Data tab and you see on the file and the document. Most of the time is reading: expect one tax return in about 30 seconds, 35 documents in about 3.5 minutes, 50 in about 7, and 100 in 10 to 12. Poll a job every 10 seconds for the first two minutes, then every 30."
    },
    {
      "name": "analysis",
      "x-displayName": "Analysis and memo",
      "description": "Read the work product back out."
    },
    {
      "name": "jobs",
      "x-displayName": "Jobs",
      "description": "One endpoint for the progress of anything asynchronous."
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "get-me",
        "summary": "Describe the key in use",
        "tags": [
          "me"
        ],
        "parameters": [],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Which organization the key acts for, its scope, and whether it is a sandbox or production key. Needs no setup and touches no data, so a `200` here means authentication is working.",
        "responses": {
          "200": {
            "description": "Describe the key in use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                },
                "example": {
                  "organization": {
                    "id": "org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "name": "Your Bank"
                  },
                  "scope": "read_write",
                  "environment": "sandbox",
                  "key_prefix": "sk_test_a1b2"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/users": {
      "get": {
        "operationId": "list-users",
        "summary": "List your organization's users",
        "tags": [
          "reference"
        ],
        "parameters": [],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Who `assigned_to` and `relationship_manager` can name. Only users who can own a deal are `assignable`.",
        "responses": {
          "200": {
            "description": "List your organization's users",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/User"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "email": "underwriter@yourbank.com",
                      "name": "Jordan Ellis",
                      "role": "MEMBER",
                      "assignable": true
                    },
                    {
                      "email": "analyst@yourbank.com",
                      "name": "Sam Ortiz",
                      "role": "VIEWER",
                      "assignable": false
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/loan-types": {
      "get": {
        "operationId": "list-loan-types",
        "summary": "List your loan types",
        "tags": [
          "reference"
        ],
        "parameters": [],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Your organization's loan types: what `loan_type` takes. Each drives a different checklist.",
        "responses": {
          "200": {
            "description": "List your loan types",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/LoanTypeOption"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "key": "cre_purchase",
                      "label": "CRE Purchase"
                    },
                    {
                      "key": "equipment",
                      "label": "Equipment Financing"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/data-types": {
      "get": {
        "operationId": "list-data-types",
        "summary": "List the data types",
        "tags": [
          "reference"
        ],
        "parameters": [],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Every kind of document a data request asks for or a file can be placed as: what `data_type` takes.",
        "responses": {
          "200": {
            "description": "List the data types",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DataTypeOption"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "key": "BUSINESS_TAX_RETURN",
                      "label": "Business Tax Return"
                    },
                    {
                      "key": "PERSONAL_TAX_RETURN",
                      "label": "Personal Tax Return"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/relationships": {
      "post": {
        "operationId": "create-relationship",
        "summary": "Create a relationship",
        "tags": [
          "relationships"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RelationshipCreate"
              },
              "example": {
                "display_name": "Brookvale Holdings",
                "external_id": "0016A00000XyZaBQAV",
                "relationship_manager": "rm@yourbank.com"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a relationship",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Relationship"
                },
                "example": {
                  "id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0016A00000XyZaBQAV",
                  "display_name": "Brookvale Holdings",
                  "status": "PROSPECT",
                  "relationship_manager": "rm@yourbank.com",
                  "fiscal_year_end_month": 12,
                  "url": "https://app.aloan.ai/relationships/crel_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:02:11Z",
                  "updated_at": "2026-09-21T14:02:11Z"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list-relationships",
        "summary": "List relationships",
        "tags": [
          "relationships"
        ],
        "parameters": [
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only the relationship carrying this id of yours."
            },
            "description": "Only the relationship carrying this id of yours."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/RelationshipStatus"
            }
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "x-aloan-example-query": "updated_after=2026-09-20T00:00:00Z&limit=50",
        "responses": {
          "200": {
            "description": "List relationships",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Relationship"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "external_id": "0016A00000XyZaBQAV",
                      "display_name": "Brookvale Holdings",
                      "status": "ACTIVE",
                      "relationship_manager": "rm@yourbank.com",
                      "fiscal_year_end_month": 12,
                      "url": "https://app.aloan.ai/relationships/crel_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "created_at": "2026-09-21T14:02:11Z",
                      "updated_at": "2026-09-21T14:02:11Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/relationships/{relationship_id}": {
      "get": {
        "operationId": "get-relationship",
        "summary": "Retrieve a relationship",
        "tags": [
          "relationships"
        ],
        "parameters": [
          {
            "name": "relationship_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "external:0016A00000XyZaBQAV"
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Accepts either Aloan's id or your own, prefixed: `/relationships/external:0016A00000XyZaBQAV`.",
        "responses": {
          "200": {
            "description": "Retrieve a relationship",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Relationship"
                },
                "example": {
                  "id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0016A00000XyZaBQAV",
                  "display_name": "Brookvale Holdings",
                  "status": "PROSPECT",
                  "relationship_manager": "rm@yourbank.com",
                  "fiscal_year_end_month": 12,
                  "url": "https://app.aloan.ai/relationships/crel_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:02:11Z",
                  "updated_at": "2026-09-21T14:02:11Z"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "update-relationship",
        "summary": "Update a relationship",
        "tags": [
          "relationships"
        ],
        "parameters": [
          {
            "name": "relationship_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RelationshipUpdate"
              },
              "example": {
                "relationship_manager": "rm2@yourbank.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Update a relationship",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Relationship"
                },
                "example": {
                  "id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0016A00000XyZaBQAV",
                  "display_name": "Brookvale Holdings",
                  "status": "PROSPECT",
                  "relationship_manager": "rm2@yourbank.com",
                  "fiscal_year_end_month": 12,
                  "url": "https://app.aloan.ai/relationships/crel_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:02:11Z",
                  "updated_at": "2026-09-22T09:14:03Z"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/relationships/{relationship_id}/entities": {
      "get": {
        "operationId": "list-entities",
        "summary": "List the parties on a relationship",
        "tags": [
          "relationships"
        ],
        "parameters": [
          {
            "name": "relationship_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "The entity pool a new deal draws from. Useful before creating a deal, so you can name existing parties rather than describing them again.",
        "responses": {
          "200": {
            "description": "List the parties on a relationship",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Entity"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "name": "Brookvale Holdings LLC",
                      "entity_type": "BUSINESS",
                      "legal_form": "LLC",
                      "tax_identifier_last4": "4417",
                      "is_primary": true
                    },
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "name": "Dana Whitfield",
                      "entity_type": "PERSON",
                      "legal_form": null,
                      "tax_identifier_last4": "0092",
                      "is_primary": false
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/relationships/{relationship_id}/loans": {
      "get": {
        "operationId": "list-loans",
        "summary": "List a relationship's booked loans",
        "tags": [
          "relationships"
        ],
        "parameters": [
          {
            "name": "relationship_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "The booked credit agreements and the notes each covers. A renewal, review or modification acts on notes: pass their ids as `note_ids` on `POST /deals`, or omit it for every active note.",
        "responses": {
          "200": {
            "description": "List a relationship's booked loans",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Loan"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "cloan_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "external_loan_id": "100-2231-7",
                      "status": "ACTIVE",
                      "origination_date": "2023-04-14",
                      "commitment_amount": "1850000.00",
                      "note_ids": [
                        "cfac_01jgx5k2m3n4p5q6r7s8t9u0v7"
                      ],
                      "originating_deal_id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v9",
                      "created_at": "2023-04-14T16:02:11Z",
                      "updated_at": "2026-09-21T14:02:11Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/uploads": {
      "post": {
        "operationId": "create-upload",
        "summary": "Declare a file and get a URL to put it at",
        "tags": [
          "uploads"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Returns a pre-authorized URL. `PUT` the raw bytes to it — the bytes go directly to our storage, not through this API, so a 300-page tax return costs you one transfer and costs us nothing. Then reference the returned `id`.",
        "x-aloan-note": "The `PUT` must send exactly the `file_type` and `file_size` you declared — both are signed into the URL. A mismatch is rejected by storage as a signature error, which reads like an auth problem but is not one: check your `Content-Type` and `Content-Length` first.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UploadCreate"
              },
              "example": {
                "file_name": "2024-tax-return.pdf",
                "file_type": "application/pdf",
                "file_size": 4718592
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Declare a file and get a URL to put it at",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Upload"
                },
                "example": {
                  "id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "upload_url": "https://s3.us-east-2.amazonaws.com/...&X-Amz-Signature=...",
                  "expires_at": "2026-09-21T15:20:05Z",
                  "status": "awaiting_bytes"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/uploads/{upload_id}/url": {
      "post": {
        "operationId": "resign-upload",
        "summary": "Get a fresh URL for an upload you declared",
        "tags": [
          "uploads"
        ],
        "parameters": [
          {
            "name": "upload_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id.",
            "example": "upl_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "For when `expires_at` passed before the bytes went up. Same upload, same declared name, type and size; a new URL for another hour.",
        "responses": {
          "200": {
            "description": "Get a fresh URL for an upload you declared",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Upload"
                },
                "example": {
                  "id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "upload_url": "https://s3.us-east-2.amazonaws.com/...&X-Amz-Signature=...",
                  "expires_at": "2026-09-21T16:20:05Z",
                  "status": "awaiting_bytes"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals": {
      "post": {
        "operationId": "create-deal",
        "summary": "Create a deal",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Name existing parties by entity id; describe new ones inline and we will create them on the relationship. Nothing beyond the relationship is required: a deal can start before the terms are known and before anyone owns it, and both can be filled in later — here, or in the app. With no parties named, the relationship's business becomes the borrower.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealCreate"
              },
              "example": {
                "relationship_id": "external:0016A00000XyZaBQAV",
                "external_id": "0066A00000LmNoPQRS",
                "assigned_to": "underwriter@yourbank.com",
                "title": "Brookvale — equipment line",
                "event_type": "ORIGINATION",
                "loan_type": "equipment",
                "entities": [
                  {
                    "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "role": "BORROWER"
                  },
                  {
                    "name": "Dana Whitfield",
                    "entity_type": "PERSON",
                    "role": "GUARANTOR",
                    "is_primary": true,
                    "guarantee": {
                      "type": "UNLIMITED"
                    }
                  }
                ],
                "facilities": [
                  {
                    "title": "Equipment Line",
                    "facility_type": "EQUIPMENT",
                    "commitment_amount": "2000000.00",
                    "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "term_months": 60,
                    "amortization_months": 60,
                    "rate_type": "FIXED",
                    "interest_rate": "0.0725",
                    "repayment_type": "MONTHLY_PI",
                    "collateral": "Blanket lien on equipment"
                  },
                  {
                    "title": "Working Capital Revolver",
                    "facility_type": "REVOLVING_LINE_OF_CREDIT",
                    "commitment_amount": "500000.00",
                    "term_months": 12,
                    "rate_type": "VARIABLE",
                    "index_name": "PRIME",
                    "spread_over_index": "0.005",
                    "repayment_type": "REVOLVING_LINE"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Create a deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                },
                "example": {
                  "id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0066A00000LmNoPQRS",
                  "relationship_id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "title": "Brookvale — equipment line",
                  "status": "IN_PROGRESS",
                  "stage": "UNDERWRITING",
                  "event_type": "ORIGINATION",
                  "loan_type": "equipment",
                  "subject_note_ids": [],
                  "assigned_to": "underwriter@yourbank.com",
                  "relationship_manager": "rm@yourbank.com",
                  "facilities": [
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": null,
                      "spread_over_index": null,
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "title": "Equipment Line",
                      "facility_type": "EQUIPMENT",
                      "commitment_amount": "2000000.00",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "term_months": 60,
                      "amortization_months": 60,
                      "rate_type": "FIXED",
                      "interest_rate": "0.0725",
                      "repayment_type": "MONTHLY_PI",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": "Blanket lien on equipment"
                    },
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": "PRIME",
                      "spread_over_index": "0.005",
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "title": "Working Capital Revolver",
                      "facility_type": "REVOLVING_LINE_OF_CREDIT",
                      "commitment_amount": "500000.00",
                      "entity_id": null,
                      "term_months": 12,
                      "amortization_months": null,
                      "rate_type": "VARIABLE",
                      "interest_rate": null,
                      "repayment_type": "REVOLVING_LINE",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": null
                    }
                  ],
                  "total_commitment": "2500000.00",
                  "currency": "USD",
                  "entities": [
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "name": "Brookvale Holdings LLC",
                      "entity_type": "BUSINESS",
                      "legal_form": "LLC",
                      "role": "BORROWER",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": null,
                      "warnings": []
                    },
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3",
                      "name": "Dana Whitfield",
                      "entity_type": "PERSON",
                      "legal_form": null,
                      "role": "GUARANTOR",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": {
                        "type": "UNLIMITED",
                        "cap": null
                      },
                      "warnings": []
                    }
                  ],
                  "data_requests_outstanding": 11,
                  "documents": 0,
                  "analyses": 0,
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:06:40Z",
                  "updated_at": "2026-09-21T14:06:40Z"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list-deals",
        "summary": "List deals",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          },
          {
            "name": "relationship_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only deals on this relationship (`crel_...` or `external:<your id>`)."
            },
            "description": "Only deals on this relationship (`crel_...` or `external:<your id>`)."
          },
          {
            "name": "external_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only the deal carrying this id of yours."
            },
            "description": "Only the deal carrying this id of yours."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DealStatus"
            }
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "With `updated_after`, this is how you keep your system in step with ours — including deals created in Aloan rather than by you.",
        "x-aloan-example-query": "updated_after=2026-09-20T00:00:00Z",
        "responses": {
          "200": {
            "description": "List deals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Deal"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "external_id": "0066A00000LmNoPQRS",
                      "relationship_id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "title": "Brookvale — equipment line",
                      "status": "IN_PROGRESS",
                      "stage": "UNDERWRITING",
                      "event_type": "ORIGINATION",
                      "loan_type": "equipment",
                      "subject_note_ids": [],
                      "assigned_to": "underwriter@yourbank.com",
                      "relationship_manager": "rm@yourbank.com",
                      "facilities": [
                        {
                          "purpose": null,
                          "interest_only_months": null,
                          "index_name": null,
                          "spread_over_index": null,
                          "rate_floor": null,
                          "rate_ceiling": null,
                          "payment_amount": null,
                          "origination_fee": null,
                          "prepayment_penalty": null,
                          "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v1",
                          "title": "Equipment Line",
                          "facility_type": "EQUIPMENT",
                          "commitment_amount": "2000000.00",
                          "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                          "term_months": 60,
                          "amortization_months": 60,
                          "rate_type": "FIXED",
                          "interest_rate": "0.0725",
                          "repayment_type": "MONTHLY_PI",
                          "interest_day_count": "ACTUAL_365",
                          "collateral": "Blanket lien on equipment"
                        },
                        {
                          "purpose": null,
                          "interest_only_months": null,
                          "index_name": "PRIME",
                          "spread_over_index": "0.005",
                          "rate_floor": null,
                          "rate_ceiling": null,
                          "payment_amount": null,
                          "origination_fee": null,
                          "prepayment_penalty": null,
                          "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v2",
                          "title": "Working Capital Revolver",
                          "facility_type": "REVOLVING_LINE_OF_CREDIT",
                          "commitment_amount": "500000.00",
                          "entity_id": null,
                          "term_months": 12,
                          "amortization_months": null,
                          "rate_type": "VARIABLE",
                          "interest_rate": null,
                          "repayment_type": "REVOLVING_LINE",
                          "interest_day_count": "ACTUAL_365",
                          "collateral": null
                        }
                      ],
                      "total_commitment": "2500000.00",
                      "currency": "USD",
                      "entities": [
                        {
                          "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                          "name": "Brookvale Holdings LLC",
                          "entity_type": "BUSINESS",
                          "legal_form": "LLC",
                          "role": "BORROWER",
                          "is_primary": true,
                          "is_collateral": false,
                          "guarantee": null,
                          "warnings": []
                        },
                        {
                          "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3",
                          "name": "Dana Whitfield",
                          "entity_type": "PERSON",
                          "legal_form": null,
                          "role": "GUARANTOR",
                          "is_primary": true,
                          "is_collateral": false,
                          "guarantee": {
                            "type": "UNLIMITED",
                            "cap": null
                          },
                          "warnings": []
                        }
                      ],
                      "data_requests_outstanding": 11,
                      "documents": 0,
                      "analyses": 0,
                      "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "created_at": "2026-09-21T14:06:40Z",
                      "updated_at": "2026-09-21T14:06:40Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/intake": {
      "post": {
        "operationId": "create-deal-intake",
        "summary": "Create a deal from a term sheet",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Send a term sheet — or a plain-language description — and we read the terms and the parties out of it. Returns a job. When the job reaches `awaiting_confirmation` its `result` carries the parsed `terms` and the `parties` we read, each with a stable `parsed_ref`, the role and kind we read, and the existing entity we propose to reuse (`proposed_entity_id`, with our `confidence`). Confirm it to create the deal. A description is read inside the request, so that job is already awaiting confirmation when it returns; a term sheet is read in the background.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntakeCreate"
              },
              "example": {
                "relationship_id": "external:0016A00000XyZaBQAV",
                "assigned_to": "underwriter@yourbank.com",
                "external_id": "0066A00000LmNoPQRS",
                "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v1"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Create a deal from a term sheet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                },
                "example": {
                  "id": "job_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "type": "deal_intake",
                  "status": "processing",
                  "progress": null,
                  "summary": null,
                  "result": null,
                  "error": null,
                  "created_at": "2026-09-21T14:09:02Z",
                  "updated_at": "2026-09-21T14:09:02Z",
                  "completed_at": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/intake/{job_id}/confirm": {
      "post": {
        "operationId": "confirm-deal-intake",
        "summary": "Confirm a parsed term sheet",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id.",
            "example": "job_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Creates the deal from the job's parsed result. Accept the entity matches we proposed, or override any of them with an entity on the relationship. The deal's `external_id` and owner are the ones you gave when you started the intake. Confirming a job that already created its deal returns that deal again, never a second one.",
        "x-aloan-note": "The full Deal object comes back, as `POST /deals` returns it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IntakeConfirm"
              },
              "example": {
                "entity_overrides": [
                  {
                    "parsed_ref": "party-1",
                    "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Confirm a parsed term sheet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                },
                "example": {
                  "id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0066A00000LmNoPQRS",
                  "relationship_id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "title": "Brookvale — equipment line",
                  "status": "IN_PROGRESS",
                  "stage": "UNDERWRITING",
                  "event_type": "ORIGINATION",
                  "loan_type": "equipment",
                  "subject_note_ids": [],
                  "assigned_to": "underwriter@yourbank.com",
                  "relationship_manager": "rm@yourbank.com",
                  "facilities": [
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": null,
                      "spread_over_index": null,
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "title": "Equipment Line",
                      "facility_type": "EQUIPMENT",
                      "commitment_amount": "2000000.00",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "term_months": 60,
                      "amortization_months": 60,
                      "rate_type": "FIXED",
                      "interest_rate": "0.0725",
                      "repayment_type": "MONTHLY_PI",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": "Blanket lien on equipment"
                    },
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": "PRIME",
                      "spread_over_index": "0.005",
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "title": "Working Capital Revolver",
                      "facility_type": "REVOLVING_LINE_OF_CREDIT",
                      "commitment_amount": "500000.00",
                      "entity_id": null,
                      "term_months": 12,
                      "amortization_months": null,
                      "rate_type": "VARIABLE",
                      "interest_rate": null,
                      "repayment_type": "REVOLVING_LINE",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": null
                    }
                  ],
                  "total_commitment": "2500000.00",
                  "currency": "USD",
                  "entities": [
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "name": "Brookvale Holdings LLC",
                      "entity_type": "BUSINESS",
                      "legal_form": "LLC",
                      "role": "BORROWER",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": null,
                      "warnings": []
                    },
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3",
                      "name": "Dana Whitfield",
                      "entity_type": "PERSON",
                      "legal_form": null,
                      "role": "GUARANTOR",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": {
                        "type": "UNLIMITED",
                        "cap": null
                      },
                      "warnings": []
                    }
                  ],
                  "data_requests_outstanding": 11,
                  "documents": 0,
                  "analyses": 0,
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:11:27Z",
                  "updated_at": "2026-09-21T14:11:27Z"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/intake/{job_id}/cancel": {
      "post": {
        "operationId": "cancel-deal-intake",
        "summary": "Cancel a parsed term sheet",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id.",
            "example": "job_01jgx5k2m3n4p5q6r7s8t9u0v3"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Discard a parsed intake without creating anything. Only a job at `awaiting_confirmation` can be cancelled; the job answers `cancelled` afterwards.",
        "responses": {
          "200": {
            "description": "Cancel a parsed term sheet",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                },
                "example": {
                  "id": "job_01jgx5k2m3n4p5q6r7s8t9u0v3",
                  "type": "deal_intake",
                  "status": "cancelled",
                  "progress": null,
                  "summary": null,
                  "result": null,
                  "error": null,
                  "created_at": "2026-09-21T14:20:05Z",
                  "updated_at": "2026-09-21T14:26:12Z",
                  "completed_at": null
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}": {
      "get": {
        "operationId": "get-deal",
        "summary": "Retrieve a deal",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "external:0066A00000LmNoPQRS"
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "The deal: its parties and terms, with counts of what hangs off it. The lists themselves — data requests, documents, analyses — are their own endpoints, so a deal with three hundred documents is still one small object. Accepts `external:<your id>`.",
        "responses": {
          "200": {
            "description": "Retrieve a deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                },
                "example": {
                  "id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0066A00000LmNoPQRS",
                  "relationship_id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "title": "Brookvale — equipment line",
                  "status": "IN_PROGRESS",
                  "stage": "UNDERWRITING",
                  "event_type": "ORIGINATION",
                  "loan_type": "equipment",
                  "subject_note_ids": [],
                  "assigned_to": "underwriter@yourbank.com",
                  "relationship_manager": "rm@yourbank.com",
                  "facilities": [
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": null,
                      "spread_over_index": null,
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "title": "Equipment Line",
                      "facility_type": "EQUIPMENT",
                      "commitment_amount": "2000000.00",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "term_months": 60,
                      "amortization_months": 60,
                      "rate_type": "FIXED",
                      "interest_rate": "0.0725",
                      "repayment_type": "MONTHLY_PI",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": "Blanket lien on equipment"
                    },
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": "PRIME",
                      "spread_over_index": "0.005",
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "title": "Working Capital Revolver",
                      "facility_type": "REVOLVING_LINE_OF_CREDIT",
                      "commitment_amount": "500000.00",
                      "entity_id": null,
                      "term_months": 12,
                      "amortization_months": null,
                      "rate_type": "VARIABLE",
                      "interest_rate": null,
                      "repayment_type": "REVOLVING_LINE",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": null
                    }
                  ],
                  "total_commitment": "2500000.00",
                  "currency": "USD",
                  "entities": [
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "name": "Brookvale Holdings LLC",
                      "entity_type": "BUSINESS",
                      "legal_form": "LLC",
                      "role": "BORROWER",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": null,
                      "warnings": []
                    },
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3",
                      "name": "Dana Whitfield",
                      "entity_type": "PERSON",
                      "legal_form": null,
                      "role": "GUARANTOR",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": {
                        "type": "UNLIMITED",
                        "cap": null
                      },
                      "warnings": []
                    }
                  ],
                  "data_requests_outstanding": 11,
                  "documents": 0,
                  "analyses": 0,
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:06:40Z",
                  "updated_at": "2026-09-21T14:06:40Z"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "update-deal",
        "summary": "Update a deal",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Terms and ownership only. Status and stage move through the platform's own workflow, not through the API.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealUpdate"
              },
              "example": {
                "assigned_to": "underwriter2@yourbank.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Update a deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                },
                "example": {
                  "id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0066A00000LmNoPQRS",
                  "relationship_id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "title": "Brookvale — equipment line",
                  "status": "IN_PROGRESS",
                  "stage": "UNDERWRITING",
                  "event_type": "ORIGINATION",
                  "loan_type": "equipment",
                  "subject_note_ids": [],
                  "assigned_to": "underwriter2@yourbank.com",
                  "relationship_manager": "rm@yourbank.com",
                  "facilities": [
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": null,
                      "spread_over_index": null,
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "title": "Equipment Line",
                      "facility_type": "EQUIPMENT",
                      "commitment_amount": "2000000.00",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "term_months": 60,
                      "amortization_months": 60,
                      "rate_type": "FIXED",
                      "interest_rate": "0.0725",
                      "repayment_type": "MONTHLY_PI",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": "Blanket lien on equipment"
                    },
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": "PRIME",
                      "spread_over_index": "0.005",
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "title": "Working Capital Revolver",
                      "facility_type": "REVOLVING_LINE_OF_CREDIT",
                      "commitment_amount": "500000.00",
                      "entity_id": null,
                      "term_months": 12,
                      "amortization_months": null,
                      "rate_type": "VARIABLE",
                      "interest_rate": null,
                      "repayment_type": "REVOLVING_LINE",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": null
                    }
                  ],
                  "total_commitment": "2500000.00",
                  "currency": "USD",
                  "entities": [
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "name": "Brookvale Holdings LLC",
                      "entity_type": "BUSINESS",
                      "legal_form": "LLC",
                      "role": "BORROWER",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": null,
                      "warnings": []
                    },
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3",
                      "name": "Dana Whitfield",
                      "entity_type": "PERSON",
                      "legal_form": null,
                      "role": "GUARANTOR",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": {
                        "type": "UNLIMITED",
                        "cap": null
                      },
                      "warnings": []
                    }
                  ],
                  "data_requests_outstanding": 11,
                  "documents": 0,
                  "analyses": 0,
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:06:40Z",
                  "updated_at": "2026-09-22T09:14:03Z"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/withdraw": {
      "post": {
        "operationId": "withdraw-deal",
        "summary": "Withdraw a deal",
        "tags": [
          "deals"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "The one status write: the borrower walked, or the opportunity died in your system. Runs the app's own transition, so an open approval request is withdrawn with it. A deal that is declined, funded or already withdrawn answers `409 conflict`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DealWithdraw"
              },
              "example": {
                "reason": "Opportunity closed lost in Salesforce"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Withdraw a deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deal"
                },
                "example": {
                  "id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "external_id": "0066A00000LmNoPQRS",
                  "relationship_id": "crel_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "title": "Brookvale — equipment line",
                  "status": "WITHDRAWN",
                  "stage": "UNDERWRITING",
                  "event_type": "ORIGINATION",
                  "loan_type": "equipment",
                  "subject_note_ids": [],
                  "assigned_to": "underwriter@yourbank.com",
                  "relationship_manager": "rm@yourbank.com",
                  "facilities": [
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": null,
                      "spread_over_index": null,
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "title": "Equipment Line",
                      "facility_type": "EQUIPMENT",
                      "commitment_amount": "2000000.00",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "term_months": 60,
                      "amortization_months": 60,
                      "rate_type": "FIXED",
                      "interest_rate": "0.0725",
                      "repayment_type": "MONTHLY_PI",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": "Blanket lien on equipment"
                    },
                    {
                      "purpose": null,
                      "interest_only_months": null,
                      "index_name": "PRIME",
                      "spread_over_index": "0.005",
                      "rate_floor": null,
                      "rate_ceiling": null,
                      "payment_amount": null,
                      "origination_fee": null,
                      "prepayment_penalty": null,
                      "id": "cfac_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "title": "Working Capital Revolver",
                      "facility_type": "REVOLVING_LINE_OF_CREDIT",
                      "commitment_amount": "500000.00",
                      "entity_id": null,
                      "term_months": 12,
                      "amortization_months": null,
                      "rate_type": "VARIABLE",
                      "interest_rate": null,
                      "repayment_type": "REVOLVING_LINE",
                      "interest_day_count": "ACTUAL_365",
                      "collateral": null
                    }
                  ],
                  "total_commitment": "2500000.00",
                  "currency": "USD",
                  "entities": [
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "name": "Brookvale Holdings LLC",
                      "entity_type": "BUSINESS",
                      "legal_form": "LLC",
                      "role": "BORROWER",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": null,
                      "warnings": []
                    },
                    {
                      "id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3",
                      "name": "Dana Whitfield",
                      "entity_type": "PERSON",
                      "legal_form": null,
                      "role": "GUARANTOR",
                      "is_primary": true,
                      "is_collateral": false,
                      "guarantee": {
                        "type": "UNLIMITED",
                        "cap": null
                      },
                      "warnings": []
                    }
                  ],
                  "data_requests_outstanding": 11,
                  "documents": 0,
                  "analyses": 0,
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1?org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:06:40Z",
                  "updated_at": "2026-09-29T11:02:45Z"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/documents": {
      "post": {
        "operationId": "upload-documents",
        "summary": "File documents onto a deal",
        "tags": [
          "documents"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Makes a retry safe: the same key and body within 24 hours replays the first response."
          }
        ],
        "x-aloan-scope": "read_write",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "File uploaded documents onto the deal. Reference uploads you have already sent the bytes for — one or many — and say where each belongs when you know: a data request, or an entity with a data type and period. Returns a job that reports each file separately, so a single bad file does not obscure the rest, and every file has an id from this moment.",
        "x-aloan-note": "The batch is validated whole before anything is used: a placement that contradicts the deal (a closed request, another entity's request, a type or period the request is not for) is `422 placement_conflict` with each offending entry in `details` by index (`documents[2].data_request_id`), an upload whose bytes never landed is `422 validation_failed` naming its position, and no upload is consumed. A file whose bytes are already on its destination is accepted as a `duplicate`, with the file it duplicates, and not processed again. A file we cannot place with confidence lands in the deal's review queue in Aloan (`awaiting_review`) for someone to resolve; the job counts it as `needs_review` and completes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentsUpload"
              },
              "example": {
                "documents": [
                  {
                    "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "external_reference": "box:1234",
                    "data_request_id": "cdr_01jgx5k2m3n4p5q6r7s8t9u0v1"
                  },
                  {
                    "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v2",
                    "external_reference": "box:1235",
                    "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "data_type": "BUSINESS_TAX_RETURN",
                    "period_end": "2024-12-31"
                  },
                  {
                    "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v3",
                    "external_reference": "box:1236",
                    "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v3"
                  },
                  {
                    "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v4",
                    "external_reference": "box:1237"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "File documents onto a deal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                },
                "example": {
                  "id": "job_01jgx5k2m3n4p5q6r7s8t9u0v2",
                  "type": "document_upload",
                  "status": "processing",
                  "progress": {
                    "total": 4,
                    "settled": 0
                  },
                  "summary": null,
                  "result": null,
                  "error": null,
                  "created_at": "2026-09-21T14:20:05Z",
                  "updated_at": "2026-09-21T14:20:05Z",
                  "completed_at": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`, `insufficient_scope`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `idempotency_key_reused`, `request_in_progress`, `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "415": {
            "description": "Error: `unsupported_media_type`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "422": {
            "description": "Error: `validation_failed`, `placement_conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list-documents",
        "summary": "List documents on a deal",
        "tags": [
          "documents"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Filed documents: what each file became once it was placed and read.",
        "x-aloan-note": "`status` is `processing` until we have read the document, then `ready` (or `failed` when extraction did not succeed). A file that could not be filed is not here; it is on `GET /deals/{id}/files`.",
        "responses": {
          "200": {
            "description": "List documents on a deal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Document"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "cdoc_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "file_id": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "external_reference": "box:1235",
                      "file_name": "2024-tax-return.pdf",
                      "data_type": "BUSINESS_TAX_RETURN",
                      "data_request_id": "cdr_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "period_start": "2024-01-01",
                      "period_end": "2024-12-31",
                      "status": "ready",
                      "concerns": [
                        {
                          "code": "missing_schedule",
                          "message": "Schedule K-1 for one partner is referenced but not included."
                        }
                      ],
                      "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/data?focus=cdoc_01jgx5k2m3n4p5q6r7s8t9u0v1&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "uploaded_at": "2026-09-21T14:20:05Z",
                      "updated_at": "2026-09-21T14:23:48Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/files": {
      "get": {
        "operationId": "list-files",
        "summary": "List files on a deal",
        "tags": [
          "documents"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          },
          {
            "name": "external_reference",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only the file carrying this id of yours."
            },
            "description": "Only the file carrying this id of yours."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/FileStatus"
            }
          },
          {
            "name": "job_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only the files one filing job created."
            },
            "description": "Only the files one filing job created."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Every file filed on the deal, through the API or in the app, with where it is in its lifecycle. Filter by `external_reference` to find yours.",
        "x-aloan-example-query": "status=awaiting_review",
        "responses": {
          "200": {
            "description": "List files on a deal",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/File"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v4",
                      "deal_id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v4",
                      "external_reference": "box:1237",
                      "file_name": "statements-q3.pdf",
                      "file_type": "application/pdf",
                      "file_size": 812331,
                      "status": "awaiting_review",
                      "placement": null,
                      "review": {
                        "kind": "question",
                        "id": "cdq_01jgx5k2m3n4p5q6r7s8t9u0v1",
                        "prompt": "Is \"BV Holdings\" the same company as Brookvale Holdings LLC?",
                        "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/data?unmatched=1&focus=cdq_01jgx5k2m3n4p5q6r7s8t9u0v1&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1"
                      },
                      "document_id": null,
                      "duplicate_of": null,
                      "error": null,
                      "concerns": [],
                      "period_start": null,
                      "period_end": null,
                      "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/data?focus=cbfile_01jgx5k2m3n4p5q6r7s8t9u0v4&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "created_at": "2026-09-21T14:20:05Z",
                      "updated_at": "2026-09-21T14:21:40Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/files/{file_id}": {
      "get": {
        "operationId": "get-file",
        "summary": "Retrieve a file",
        "tags": [
          "documents"
        ],
        "parameters": [
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id.",
            "example": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v1"
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Retrieve a file",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/File"
                },
                "example": {
                  "id": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "deal_id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v2",
                  "external_reference": "box:1235",
                  "file_name": "brookvale-2024-1120s.pdf",
                  "file_type": "application/pdf",
                  "file_size": 4718592,
                  "status": "filed",
                  "placement": {
                    "data_request_id": "cdr_01jgx5k2m3n4p5q6r7s8t9u0v2",
                    "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "data_type": "BUSINESS_TAX_RETURN",
                    "period_end": "2024-12-31",
                    "source": "caller"
                  },
                  "review": null,
                  "document_id": "cdoc_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "duplicate_of": null,
                  "error": null,
                  "concerns": [],
                  "period_start": "2024-01-01",
                  "period_end": "2024-12-31",
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/data?focus=cbfile_01jgx5k2m3n4p5q6r7s8t9u0v1&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "created_at": "2026-09-21T14:20:05Z",
                  "updated_at": "2026-09-21T14:21:40Z"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/questions": {
      "get": {
        "operationId": "list-questions",
        "summary": "List the deal's open questions",
        "tags": [
          "documents"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/QuestionStatus"
                }
              ],
              "description": "`OPEN` is the one worth polling."
            },
            "description": "`OPEN` is the one worth polling."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "What a person in Aloan needs to decide about a file. Read-only in v1: each `url` opens the question in the app, which is where it is answered. Once answered, the file it covered moves on (`filed`, `dismissed` or `failed`).",
        "x-aloan-example-query": "status=OPEN",
        "responses": {
          "200": {
            "description": "List the deal's open questions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Question"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "cdq_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "kind": "IDENTITY_LINK",
                      "status": "OPEN",
                      "prompt": "Is \"BV Holdings\" the same company as Brookvale Holdings LLC?",
                      "why": "A bank statement names an account holder we cannot place on the deal.",
                      "file_id": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v4",
                      "document_id": null,
                      "suggestions": [
                        {
                          "id": "0",
                          "label": "Yes, the same company."
                        },
                        {
                          "id": "1",
                          "label": "No, dismiss this document."
                        }
                      ],
                      "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/data?unmatched=1&focus=cdq_01jgx5k2m3n4p5q6r7s8t9u0v1&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "created_at": "2026-09-21T14:22:10Z",
                      "answered_at": null,
                      "updated_at": "2026-09-21T14:22:10Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/data-requests": {
      "get": {
        "operationId": "list-data-requests",
        "summary": "List outstanding requirements",
        "tags": [
          "documents"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/DataRequestStatus"
            }
          },
          {
            "name": "entity_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only the requests on this party."
            },
            "description": "Only the requests on this party."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "What the deal still needs. The list to drive a borrower chase from.",
        "responses": {
          "200": {
            "description": "List outstanding requirements",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/DataRequest"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "cdr_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "label": "2025 business tax return",
                      "data_type": "BUSINESS_TAX_RETURN",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "status": "PENDING",
                      "required": true,
                      "due_at": "2026-10-15T00:00:00Z",
                      "updated_at": "2026-09-21T14:06:40Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/analyses": {
      "get": {
        "operationId": "list-analyses",
        "summary": "List published analyses",
        "tags": [
          "analysis"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "updated_after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date-time",
              "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
            },
            "description": "Only records changed since (inclusive). With a newest-first `order`, a plain lower bound."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "description": "1–200. Defaults to 50."
            },
            "description": "1–200. Defaults to 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
            },
            "description": "From `next_cursor` on the previous page. Send the same filters and `order`."
          },
          {
            "name": "order",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/ListOrder"
                }
              ],
              "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
            },
            "description": "`updated_at` (default): oldest change first, for `updated_after` sweeps. `-updated_at`: newest change first, for polling what changed. `-created_at`: newest record first, for polling what's new. Ties break on `id` in the same direction."
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "$ref": "#/components/schemas/AnalysisType"
            }
          },
          {
            "name": "entity_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "description": "Only analyses for this party."
            },
            "description": "Only analyses for this party."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Published analyses only — the figures an analyst has committed to. Work in progress is deliberately not exposed: it changes under you.",
        "x-aloan-note": "The list omits `table` — it can be large. Fetch a single analysis to get it.",
        "responses": {
          "200": {
            "description": "List published analyses",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Analysis"
                      }
                    },
                    "has_more": {
                      "type": "boolean",
                      "description": "Whether another page follows."
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Pass back as `cursor` for the next page."
                    }
                  },
                  "required": [
                    "data",
                    "has_more",
                    "next_cursor"
                  ]
                },
                "example": {
                  "data": [
                    {
                      "id": "canalysis_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "type": "dscr_analysis",
                      "title": "Brookvale Holdings — DSCR",
                      "description": "",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "format": "grid",
                      "figures": {
                        "dscr": {
                          "value": "1.42",
                          "unit": "ratio",
                          "label": "DSCR",
                          "as_of": "2024-12-31",
                          "period_start": "2024-01-01",
                          "period_end": "2024-12-31",
                          "scenario": null,
                          "basis": "business"
                        }
                      },
                      "is_stale": false,
                      "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/analysis?node=canalysis_01jgx5k2m3n4p5q6r7s8t9u0v1&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "published_at": "2026-09-21T15:41:12Z",
                      "updated_at": "2026-09-21T15:41:12Z"
                    },
                    {
                      "id": "canalysis_01jgx5k2m3n4p5q6r7s8t9u0v2",
                      "type": "combined_balance_sheet",
                      "title": "Brookvale Holdings — Balance Sheet",
                      "description": "Excludes closely-held business interests",
                      "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "format": "grid",
                      "figures": {
                        "net_worth": {
                          "value": "7170600.00",
                          "unit": "currency",
                          "label": "Net Worth",
                          "as_of": "2024-12-31",
                          "period_start": null,
                          "period_end": "2024-12-31",
                          "scenario": null,
                          "basis": null
                        },
                        "total_assets": {
                          "value": "19480200.00",
                          "unit": "currency",
                          "label": "Total Assets",
                          "as_of": "2024-12-31",
                          "period_start": null,
                          "period_end": "2024-12-31",
                          "scenario": null,
                          "basis": null
                        },
                        "total_liabilities": {
                          "value": "12309600.00",
                          "unit": "currency",
                          "label": "Total Liabilities",
                          "as_of": "2024-12-31",
                          "period_start": null,
                          "period_end": "2024-12-31",
                          "scenario": null,
                          "basis": null
                        }
                      },
                      "is_stale": false,
                      "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/analysis?node=canalysis_01jgx5k2m3n4p5q6r7s8t9u0v2&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                      "published_at": "2026-09-21T15:44:02Z",
                      "updated_at": "2026-09-21T15:44:02Z"
                    }
                  ],
                  "has_more": false,
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/analyses/{analysis_id}": {
      "get": {
        "operationId": "get-analysis",
        "summary": "Retrieve one analysis",
        "tags": [
          "analysis"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "analysis_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id.",
            "example": "canalysis_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/AnalysisDownloadFormat"
                }
              ],
              "description": "`json` (default) or `xlsx`: the same sheet the app's Export button writes."
            },
            "description": "`json` (default) or `xlsx`: the same sheet the app's Export button writes."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "The same object with `table` included. Every tabular analysis returns the same grid whatever its type, so one parser reads all of them: `columns` are the periods (or, for a table whose columns are not periods — a debt schedule, a collateral schedule — its own headings), `rows` are the lines, and a row's `values` are keyed by column. Ask for `format=xlsx` to get the same table as the spreadsheet the app's own Export button writes.",
        "x-aloan-note": "A row's `kind` is `line`, `subtotal`, `total`, `ratio` or `section` (a heading with no values), and `depth` is its indent under the line above. A column's `kind` is `value`, or `percent` for the common-size column beside a period. Values are decimal strings, or null where the period has no figure — a ratio row is a multiple to four decimals (`1.42` is 1.42x), a percent column is already scaled (`12.5` is 12.5%), everything else is currency to the cent.",
        "responses": {
          "200": {
            "description": "Retrieve one analysis",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Analysis"
                },
                "example": {
                  "id": "canalysis_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "type": "dscr_analysis",
                  "title": "Brookvale Holdings — DSCR",
                  "description": "",
                  "entity_id": "asubj_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "format": "grid",
                  "figures": {
                    "dscr": {
                      "value": "1.42",
                      "unit": "ratio",
                      "label": "DSCR",
                      "as_of": "2024-12-31",
                      "period_start": "2024-01-01",
                      "period_end": "2024-12-31",
                      "scenario": null,
                      "basis": "business"
                    }
                  },
                  "is_stale": false,
                  "url": "https://app.aloan.ai/deals/clapp_01jgx5k2m3n4p5q6r7s8t9u0v1/analysis?node=canalysis_01jgx5k2m3n4p5q6r7s8t9u0v1&org=org_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "published_at": "2026-09-21T15:41:12Z",
                  "updated_at": "2026-09-21T15:41:12Z",
                  "table": {
                    "columns": [
                      {
                        "key": "fy2023",
                        "label": "FY2023",
                        "period_start": "2023-01-01",
                        "period_end": "2023-12-31",
                        "kind": "value",
                        "scenario": null,
                        "basis": "actual",
                        "source": null
                      },
                      {
                        "key": "fy2024",
                        "label": "FY2024",
                        "period_start": "2024-01-01",
                        "period_end": "2024-12-31",
                        "kind": "value",
                        "scenario": null,
                        "basis": "actual",
                        "source": null
                      }
                    ],
                    "rows": [
                      {
                        "key": "available_cash_flow",
                        "label": "Available Cash Flow",
                        "depth": 0,
                        "kind": "subtotal",
                        "unit": "currency",
                        "values": {
                          "fy2023": "1043900.00",
                          "fy2024": "1184320.00"
                        }
                      },
                      {
                        "key": "total_debt_service",
                        "label": "Total Debt Service",
                        "depth": 0,
                        "kind": "subtotal",
                        "unit": "currency",
                        "values": {
                          "fy2023": "796100.00",
                          "fy2024": "834000.00"
                        }
                      },
                      {
                        "key": "dscr",
                        "label": "DSCR",
                        "depth": 0,
                        "kind": "ratio",
                        "unit": "ratio",
                        "values": {
                          "fy2023": "1.31",
                          "fy2024": "1.42"
                        }
                      }
                    ]
                  }
                }
              },
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/deals/{deal_id}/credit-memo": {
      "get": {
        "operationId": "get-credit-memo",
        "summary": "Retrieve the credit memo",
        "tags": [
          "analysis"
        ],
        "parameters": [
          {
            "name": "deal_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id, or your own as `external:<id>` where the object carries one.",
            "example": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/MemoDownloadFormat"
                }
              ],
              "description": "`json` (default) or `docx`."
            },
            "description": "`json` (default) or `docx`."
          },
          {
            "name": "revision",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "description": "An earlier revision. Defaults to the latest."
            },
            "description": "An earlier revision. Defaults to the latest."
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "The latest submitted revision of the memo, as a document or as the Word file the approvers read. Every submission for approval cuts a revision; `status` is the memo's live status, so while changes are requested (`CHANGES_REQUESTED`) this is still the last revision submitted, never the analyst's working copy. A memo never submitted returns `409 conflict` (`reason: memo_not_submitted`). The JSON form carries `revision`, `latest_revision`, `submitted_at`, `approved_at`, its `dates` (prepared, submitted, decided) and `document.nodes` — the same headings, paragraphs and tables the Word file is built from, in order.",
        "responses": {
          "200": {
            "description": "Retrieve the credit memo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreditMemo"
                },
                "example": {
                  "deal_id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                  "revision": 2,
                  "latest_revision": 2,
                  "status": "APPROVED",
                  "submitted_at": "2026-09-28T16:40:11Z",
                  "approved_at": "2026-09-30T13:05:52Z",
                  "dates": [
                    {
                      "label": "Prepared",
                      "date": "2026-09-26"
                    },
                    {
                      "label": "Submitted",
                      "date": "2026-09-28"
                    },
                    {
                      "label": "Approved",
                      "date": "2026-09-30"
                    }
                  ],
                  "document": {
                    "title": "Credit Memorandum — Brookvale Holdings LLC",
                    "subtitle_lines": [
                      "Equipment Line · $2,000,000",
                      "Working Capital Revolver · $500,000"
                    ],
                    "logo": null,
                    "nodes": [
                      {
                        "type": "heading",
                        "level": 1,
                        "text": "Executive Summary"
                      },
                      {
                        "type": "paragraph",
                        "text": "Brookvale Holdings LLC requests a $2,000,000 equipment line..."
                      }
                    ]
                  }
                }
              },
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Error: `invalid_request`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "409": {
            "description": "Error: `conflict`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{job_id}": {
      "get": {
        "operationId": "get-job",
        "summary": "Retrieve a job",
        "tags": [
          "jobs"
        ],
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Aloan's id.",
            "example": "job_01jgx5k2m3n4p5q6r7s8t9u0v2"
          }
        ],
        "x-aloan-scope": "read",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "A `deal_intake` job at `awaiting_confirmation` carries `result.parties` — `{parsed_ref, parsed_name, role, entity_type, legal_form, proposed_entity_id, confidence}` — and `result.terms` as read from the document; once confirmed, `result.deal_id`. A `document_upload` job is `processing` with `progress` until every file has settled, then `completed` with `summary` counts and `result.files[]` — a record of how each file stood at that moment (`outcome` is `filed`, `needs_review`, `duplicate` or `failed`). The job is frozen then; a file that needed review and was filed an hour later says so on `GET /files/{id}`, not on the job.",
        "responses": {
          "200": {
            "description": "Retrieve a job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Job"
                },
                "example": {
                  "id": "job_01jgx5k2m3n4p5q6r7s8t9u0v2",
                  "type": "document_upload",
                  "status": "completed",
                  "progress": {
                    "total": 2,
                    "settled": 2
                  },
                  "summary": {
                    "filed": 1,
                    "needs_review": 1,
                    "duplicate": 0,
                    "failed": 0
                  },
                  "result": {
                    "deal_id": "clapp_01jgx5k2m3n4p5q6r7s8t9u0v1",
                    "files": [
                      {
                        "file_id": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v1",
                        "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v1",
                        "external_reference": "box:1234",
                        "file_name": "2024-tax-return.pdf",
                        "outcome": "filed",
                        "document_id": "cdoc_01jgx5k2m3n4p5q6r7s8t9u0v1",
                        "data_request_id": "cdr_01jgx5k2m3n4p5q6r7s8t9u0v1",
                        "error": null
                      },
                      {
                        "file_id": "cbfile_01jgx5k2m3n4p5q6r7s8t9u0v4",
                        "upload_id": "upl_01jgx5k2m3n4p5q6r7s8t9u0v4",
                        "external_reference": "box:1237",
                        "file_name": "rent-roll.xlsx",
                        "outcome": "needs_review",
                        "document_id": null,
                        "data_request_id": null,
                        "error": null
                      }
                    ]
                  },
                  "error": null,
                  "created_at": "2026-09-21T14:20:05Z",
                  "updated_at": "2026-09-21T14:23:48Z",
                  "completed_at": "2026-09-21T14:23:48Z"
                }
              }
            }
          },
          "401": {
            "description": "Error: `unauthorized`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Error: `ip_not_allowed`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Error: `not_found`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Error: `rate_limited`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Error: `server_error`",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Analysis": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^canalysis_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `canalysis_`."
          },
          "type": {
            "$ref": "#/components/schemas/AnalysisType"
          },
          "title": {
            "type": "string",
            "description": "What the analyst called it."
          },
          "description": {
            "type": "string",
            "description": "The analyst's note on which view this is."
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "The party analysed. Null for deal-wide analyses."
          },
          "format": {
            "allOf": [
              {
                "$ref": "#/components/schemas/AnalysisFormat"
              }
            ],
            "description": "Branch on this before reading `table`."
          },
          "figures": {
            "type": "object",
            "additionalProperties": {
              "$ref": "#/components/schemas/Figure"
            },
            "description": "Named scalars published beside the table, by key."
          },
          "is_stale": {
            "type": "boolean",
            "description": "True when source data changed after this was published."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The analysis in the Aloan app, for a person to open."
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          },
          "table": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Grid"
              },
              {
                "type": "null"
              }
            ],
            "description": "The analysis as a grid. Present when `format` is `grid` and you fetched the single analysis."
          },
          "content": {
            "type": "string",
            "description": "The written content, when `format` is `markdown` and you fetched the single analysis."
          }
        },
        "required": [
          "id",
          "type",
          "title",
          "description",
          "entity_id",
          "format",
          "figures",
          "is_stale",
          "url",
          "published_at",
          "updated_at"
        ],
        "description": "A published piece of analysis — a spread, a DSCR worksheet, a global cash flow. Only published analyses are exposed: they are what an analyst has committed to, and the only ones stable enough to store in another system."
      },
      "AnalysisDownloadFormat": {
        "type": "string",
        "enum": [
          "json",
          "xlsx"
        ]
      },
      "AnalysisFormat": {
        "type": "string",
        "enum": [
          "grid",
          "chart",
          "markdown"
        ]
      },
      "AnalysisType": {
        "type": "string",
        "enum": [
          "combined_income_statement",
          "combined_trust_income_statement",
          "combined_balance_sheet",
          "combined_cash_flow",
          "combined_personal_income_statement",
          "combined_personal_balance_sheet",
          "combined_operating_statement",
          "consolidated_income_statement",
          "consolidated_balance_sheet",
          "dscr_analysis",
          "personal_income",
          "property_schedule",
          "ratios_analysis",
          "cash_bridge",
          "global_cash_flow",
          "cash_flow_chart",
          "custom_table",
          "metrics_table",
          "debt_service_summary",
          "debt_schedule",
          "bank_statement_monthly_summary",
          "bank_statement_cash_flow_chart",
          "bank_statement_score_card",
          "bank_statement_risk_flags",
          "rent_roll_summary",
          "markdown_content",
          "collateral_analysis",
          "pre_screen_summary"
        ]
      },
      "Concern": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "`period_mismatch`, `type_mismatch`, or a document finding's code."
          },
          "message": {
            "type": "string"
          },
          "observed": {
            "type": "string",
            "description": "What the document showed (placement concerns)."
          },
          "declared": {
            "type": "string",
            "description": "What was declared (placement concerns)."
          }
        },
        "required": [
          "code",
          "message"
        ],
        "description": "A disagreement between a placement and the document, or a finding from reading it."
      },
      "CreditMemo": {
        "type": "object",
        "properties": {
          "deal_id": {
            "type": "string",
            "pattern": "^clapp_[0-9a-z]+$"
          },
          "revision": {
            "type": "integer",
            "description": "The revision this is: 1 for the first submission."
          },
          "latest_revision": {
            "type": "integer",
            "description": "The memo's current revision number."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/CreditMemoStatus"
              }
            ],
            "description": "The memo's live status."
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "approved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When this revision was decided, if it was."
          },
          "dates": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/MemoDate"
                }
              ],
              "description": "The dates printed under the memo's title, in order."
            },
            "description": "The dates printed under the memo's title, in order."
          },
          "document": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/MemoDocument"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "deal_id",
          "revision",
          "latest_revision",
          "status",
          "submitted_at",
          "approved_at",
          "dates",
          "document"
        ],
        "description": "The credit memo as submitted for approval. Every submission cuts a revision; the API serves revisions, never the analyst's working copy."
      },
      "CreditMemoStatus": {
        "type": "string",
        "enum": [
          "DRAFT",
          "SUBMITTED",
          "CHANGES_REQUESTED",
          "APPROVED",
          "DECLINED"
        ]
      },
      "DataRequest": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^cdr_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `cdr_`."
          },
          "label": {
            "type": "string",
            "description": "Human-readable description of what is being asked for."
          },
          "data_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Machine-readable type, e.g. `BUSINESS_TAX_RETURN`."
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "The party this is being asked of."
          },
          "status": {
            "$ref": "#/components/schemas/DataRequestStatus"
          },
          "required": {
            "type": "boolean",
            "description": "Whether the deal can proceed without it."
          },
          "due_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "label",
          "data_type",
          "entity_id",
          "status",
          "required",
          "due_at",
          "updated_at"
        ],
        "description": "One outstanding item on a deal's checklist — a tax return, a rent roll, a debt schedule. The list of what is still needed from the borrower."
      },
      "DataRequestStatus": {
        "type": "string",
        "enum": [
          "PENDING",
          "IN_PROGRESS",
          "REVIEWING",
          "ACCEPTED",
          "COMPLETED",
          "EXCEPTION",
          "REJECTED",
          "CANCELLED"
        ]
      },
      "DataType": {
        "type": "string",
        "enum": [
          "FINANCIAL_STATEMENTS",
          "AR_AGING",
          "AP_AGING",
          "INVENTORY_AGING",
          "BUSINESS_TAX_RETURN",
          "BUSINESS_TAX_RETURN_SCHEDULE_K",
          "PERSONAL_TAX_RETURN",
          "TRUST_TAX_RETURN",
          "TAX_COMPLIANCE_HISTORY",
          "TAX_LIABILITIES_SCHEDULE",
          "TAX_TRANSCRIPT",
          "PERSONAL_FINANCIAL_STATEMENT",
          "PERSONAL_CREDIT_REPORT",
          "PAY_STUB",
          "RESUME",
          "KYC",
          "FORMATION_DOCUMENTS",
          "FICTITIOUS_NAME_STATEMENT",
          "BUSINESS_LICENSE",
          "CAP_TABLE",
          "EIN_LETTER",
          "CORPORATE_RESOLUTION",
          "W_9",
          "REGULATORY_DISCLOSURES",
          "INSURANCE_CLAIMS",
          "SETTLEMENT_DOCUMENTS",
          "PURCHASE_AGREEMENT",
          "APPRAISAL",
          "INVOICE",
          "CONSTRUCTION_CONTRACT",
          "CONSTRUCTION_BUDGET",
          "PLANS_AND_SPECS",
          "PERMITS",
          "RENT_ROLL",
          "LEASE",
          "ENVIRONMENTAL_REPORT",
          "FLOOD_CERTIFICATE",
          "BANK_STATEMENTS",
          "INVESTMENT_STATEMENT",
          "BUSINESS_CREDIT_REPORT",
          "REAL_ESTATE_OWNED",
          "DEBT_SCHEDULE",
          "RELATED_PARTY_TRANSACTIONS",
          "OFF_BALANCE_SHEET_DISCLOSURE",
          "SUPPLIER_CONTRACTS",
          "DISTRIBUTOR_AGREEMENTS",
          "PRICING_AGREEMENTS",
          "MATERIAL_CONTRACTS",
          "RISK_DISCLOSURE",
          "GIFT_TAX_RETURN",
          "CERTIFICATE_OF_GOOD_STANDING",
          "TRUST_DOCUMENT",
          "PROPERTY_RECORDS",
          "PROPERTY_IMPROVEMENT_PLAN",
          "SURVEY",
          "TITLE_WORK",
          "GROUND_LEASE",
          "SNDA",
          "TENANT_ESTOPPELS",
          "MASTER_DEED",
          "DEED_RESTRICTIONS",
          "MARKET_STUDY",
          "INSURANCE_CERTIFICATE",
          "SWORN_STATEMENT",
          "TITLE_CERTIFICATE_OF_ORIGIN",
          "VEHICLE_TITLE",
          "FIELD_AUDIT",
          "SITE_INSPECTION",
          "STAR_REPORT",
          "ASSET_LIST",
          "INVENTORY_LIST",
          "PAYOFF_STATEMENT",
          "TERM_SHEET",
          "DEAL_BACKGROUND",
          "OFFERING_MEMORANDUM",
          "LOAN_APPLICATION",
          "SBA_AUTHORIZATION",
          "SBA_GUARANTY",
          "SBA_FORM",
          "SBA_CITIZENSHIP_CERTIFICATION",
          "IRS_FORM_4506C",
          "GOVERNMENT_ID",
          "FRANCHISE_AGREEMENT",
          "EQUITY_INJECTION_VERIFICATION",
          "BENEFICIAL_OWNERSHIP",
          "UCC_SEARCH",
          "UCC_FILING",
          "OFAC_REPORT",
          "CAIVRS_CHECK",
          "SAM_SEARCH",
          "BACKGROUND_SEARCH",
          "LITIGATION_SEARCH",
          "BUSINESS_PLAN",
          "CUSTOM"
        ]
      },
      "DataTypeOption": {
        "type": "object",
        "properties": {
          "key": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DataType"
              }
            ],
            "description": "What `data_type` takes."
          },
          "label": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "label"
        ]
      },
      "Deal": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^clapp_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `clapp_`."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your id for this deal. Unique within your organization. Set once: a deal that already carries one of your ids keeps it until you clear it with `null`."
          },
          "relationship_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^crel_[0-9a-z]+$",
            "description": "The parent relationship."
          },
          "title": {
            "type": "string",
            "description": "Deal label. Falls back to the primary borrower's name."
          },
          "status": {
            "$ref": "#/components/schemas/DealStatus"
          },
          "stage": {
            "$ref": "#/components/schemas/DealStage"
          },
          "event_type": {
            "$ref": "#/components/schemas/EventType"
          },
          "loan_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your organization's loan type, a key from `GET /loan-types`. Drives the checklist."
          },
          "subject_note_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^cfac_[0-9a-z]+$"
            },
            "description": "For a renewal, review or modification: the notes (booked facilities) it acts on. Empty for an origination."
          },
          "assigned_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the deal's owner: the underwriter once the deal is at `UNDERWRITING`, the relationship manager while it is at `PRE_QUALIFICATION`. Null until someone is assigned."
          },
          "relationship_manager": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the RM on the deal. Defaults from the relationship."
          },
          "facilities": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Facility"
                }
              ],
              "description": "What is being asked for, facility by facility. This is the deal's terms."
            },
            "description": "What is being asked for, facility by facility. This is the deal's terms."
          },
          "total_commitment": {
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Sum of the facilities' commitment amounts. Decimal string."
          },
          "currency": {
            "type": "string",
            "description": "ISO 4217, e.g. `USD`."
          },
          "entities": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Party"
                }
              ],
              "description": "Every party on this deal. A party the app has not yet bound to an entity has `id: null` and a warning; it is listed, never omitted."
            },
            "description": "Every party on this deal. A party the app has not yet bound to an entity has `id: null` and a warning; it is listed, never omitted."
          },
          "data_requests_outstanding": {
            "type": "integer",
            "description": "Checklist items still open. The list itself is `GET /deals/{id}/data-requests`."
          },
          "documents": {
            "type": "integer",
            "description": "Documents filed on the deal. The list itself is `GET /deals/{id}/documents`."
          },
          "analyses": {
            "type": "integer",
            "description": "Published analyses. The list itself is `GET /deals/{id}/analyses`."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The deal in the Aloan app, for a person to open."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Moves when the deal's parties, terms, checklist, documents or memo change, not only its own fields. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "external_id",
          "relationship_id",
          "title",
          "status",
          "stage",
          "event_type",
          "loan_type",
          "subject_note_ids",
          "assigned_to",
          "relationship_manager",
          "facilities",
          "total_commitment",
          "currency",
          "entities",
          "data_requests_outstanding",
          "documents",
          "analyses",
          "url",
          "created_at",
          "updated_at"
        ],
        "description": "One credit request against a relationship: an origination, a renewal, a review or a modification. Everything the platform produces — documents, data requests, analyses, the memo — hangs off a deal."
      },
      "DealCreate": {
        "type": "object",
        "properties": {
          "relationship_id": {
            "type": "string",
            "description": "Aloan id, or `external:<your id>`."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Your id for this deal. Unique within your organization."
          },
          "assigned_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the deal owner — the underwriter for a deal at `UNDERWRITING`, the RM at `PRE_QUALIFICATION`. Rejected if it is not a user in your organization."
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Deal label."
          },
          "event_type": {
            "type": "string",
            "enum": [
              "ORIGINATION",
              "RENEWAL",
              "REVIEW",
              "MODIFICATION",
              "COVENANT_TEST"
            ],
            "description": "`ORIGINATION` (default), `RENEWAL`, `REVIEW` or `MODIFICATION`. A renewal, review or modification acts on the relationship's notes (its booked facilities) and starts from their parties and terms, so it takes no `entities` or `facilities`; `note_ids` narrows which notes are in scope."
          },
          "stage": {
            "type": "string",
            "enum": [
              "PRE_QUALIFICATION",
              "UNDERWRITING"
            ],
            "description": "`UNDERWRITING` (default) or `PRE_QUALIFICATION`."
          },
          "loan_type": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "A key from `GET /loan-types`. Drives the checklist; can be set later with `PATCH`."
          },
          "note_ids": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "For `RENEWAL`, `REVIEW` and `MODIFICATION`: the notes in scope, as facility ids (`cfac_`) from `GET /relationships/{id}/loans`. Omit for every active note on the relationship."
          },
          "review_period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "For a `REVIEW`: the period end it reviews. Defaults from the relationship's fiscal year end."
          },
          "entities": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/EntityInput"
                }
              ],
              "description": "Existing parties by `entity_id`, or new ones by `name` and `entity_type`; we create new ones on the relationship. With none, the relationship's business becomes the borrower."
            },
            "description": "Existing parties by `entity_id`, or new ones by `name` and `entity_type`; we create new ones on the relationship. With none, the relationship's business becomes the borrower."
          },
          "facilities": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/FacilityInput"
                }
              ],
              "description": "What is being asked for, when you know it. Leave it out when the terms are not settled yet."
            },
            "description": "What is being asked for, when you know it. Leave it out when the terms are not settled yet."
          }
        },
        "required": [
          "relationship_id"
        ],
        "description": "A new deal. Only `relationship_id` is required: terms and ownership can come later."
      },
      "DealStage": {
        "type": "string",
        "enum": [
          "PRE_QUALIFICATION",
          "UNDERWRITING"
        ]
      },
      "DealStatus": {
        "type": "string",
        "enum": [
          "IN_PROGRESS",
          "PENDING_APPROVAL",
          "APPROVED",
          "FUNDED",
          "DECLINED",
          "WITHDRAWN",
          "COMPLETED"
        ]
      },
      "DealUpdate": {
        "type": "object",
        "properties": {
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Claim it with your id while it has none; `null` clears it. A record that already carries another of your ids answers `409 conflict` with `reason: external_id_already_set` — clear it first to re-point it."
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Deal label."
          },
          "assigned_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the deal owner; `null` unassigns."
          },
          "loan_type": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 100,
            "description": "A key from `GET /loan-types`. Re-derives the checklist; `null` clears it."
          },
          "facilities": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/FacilityInput"
                }
              ],
              "description": "Replaces the deal's facilities. Send a facility's `id` to update it in place; omit the `id` to add one, and omit a facility entirely to remove it."
            },
            "description": "Replaces the deal's facilities. Send a facility's `id` to update it in place; omit the `id` to add one, and omit a facility entirely to remove it."
          }
        },
        "description": "Terms and ownership. Status and stage move through the platform's own workflow."
      },
      "DealWithdraw": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 2000,
            "description": "Why. Shown in the app."
          }
        },
        "required": [
          "reason"
        ],
        "description": "Why the deal is being withdrawn."
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^cdoc_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `cdoc_`."
          },
          "file_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cbfile_[0-9a-z]+$",
            "description": "The file it came from, when it was filed as one."
          },
          "external_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your id for the file, as you sent it when filing."
          },
          "file_name": {
            "type": "string",
            "description": "As uploaded."
          },
          "data_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the document is, e.g. `BUSINESS_TAX_RETURN`."
          },
          "data_request_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdr_[0-9a-z]+$",
            "description": "The checklist item it satisfies."
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "The party it belongs to."
          },
          "period_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Once read."
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "The period the document covers, once read."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/DocumentStatus"
              }
            ],
            "description": "`processing` while we extract its contents, then `ready`, or `failed` when the extraction did not succeed."
          },
          "concerns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Concern"
            }
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Where to open it in the Aloan app."
          },
          "uploaded_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "file_id",
          "external_reference",
          "file_name",
          "data_type",
          "data_request_id",
          "entity_id",
          "period_start",
          "period_end",
          "status",
          "concerns",
          "url",
          "uploaded_at",
          "updated_at"
        ],
        "description": "A file on a deal, filed against its checklist and the party it belongs to. Created by uploading; read back from the deal's document list."
      },
      "DocumentInput": {
        "type": "object",
        "properties": {
          "upload_id": {
            "type": "string",
            "description": "An upload whose bytes you have sent."
          },
          "external_reference": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Your own id for the file (a Box id), echoed back on the file, the document and the job."
          },
          "data_request_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "File it on this checklist item; matching is skipped. The request must be on the deal and open."
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The party it belongs to. Alone, we choose among the entity's open requests, creating one of the type we read when none fits."
          },
          "data_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "FINANCIAL_STATEMENTS",
              "AR_AGING",
              "AP_AGING",
              "INVENTORY_AGING",
              "BUSINESS_TAX_RETURN",
              "BUSINESS_TAX_RETURN_SCHEDULE_K",
              "PERSONAL_TAX_RETURN",
              "TRUST_TAX_RETURN",
              "TAX_COMPLIANCE_HISTORY",
              "TAX_LIABILITIES_SCHEDULE",
              "TAX_TRANSCRIPT",
              "PERSONAL_FINANCIAL_STATEMENT",
              "PERSONAL_CREDIT_REPORT",
              "PAY_STUB",
              "RESUME",
              "KYC",
              "FORMATION_DOCUMENTS",
              "FICTITIOUS_NAME_STATEMENT",
              "BUSINESS_LICENSE",
              "CAP_TABLE",
              "EIN_LETTER",
              "CORPORATE_RESOLUTION",
              "W_9",
              "REGULATORY_DISCLOSURES",
              "INSURANCE_CLAIMS",
              "SETTLEMENT_DOCUMENTS",
              "PURCHASE_AGREEMENT",
              "APPRAISAL",
              "INVOICE",
              "CONSTRUCTION_CONTRACT",
              "CONSTRUCTION_BUDGET",
              "PLANS_AND_SPECS",
              "PERMITS",
              "RENT_ROLL",
              "LEASE",
              "ENVIRONMENTAL_REPORT",
              "FLOOD_CERTIFICATE",
              "BANK_STATEMENTS",
              "INVESTMENT_STATEMENT",
              "BUSINESS_CREDIT_REPORT",
              "REAL_ESTATE_OWNED",
              "DEBT_SCHEDULE",
              "RELATED_PARTY_TRANSACTIONS",
              "OFF_BALANCE_SHEET_DISCLOSURE",
              "SUPPLIER_CONTRACTS",
              "DISTRIBUTOR_AGREEMENTS",
              "PRICING_AGREEMENTS",
              "MATERIAL_CONTRACTS",
              "RISK_DISCLOSURE",
              "GIFT_TAX_RETURN",
              "CERTIFICATE_OF_GOOD_STANDING",
              "TRUST_DOCUMENT",
              "PROPERTY_RECORDS",
              "PROPERTY_IMPROVEMENT_PLAN",
              "SURVEY",
              "TITLE_WORK",
              "GROUND_LEASE",
              "SNDA",
              "TENANT_ESTOPPELS",
              "MASTER_DEED",
              "DEED_RESTRICTIONS",
              "MARKET_STUDY",
              "INSURANCE_CERTIFICATE",
              "SWORN_STATEMENT",
              "TITLE_CERTIFICATE_OF_ORIGIN",
              "VEHICLE_TITLE",
              "FIELD_AUDIT",
              "SITE_INSPECTION",
              "STAR_REPORT",
              "ASSET_LIST",
              "INVENTORY_LIST",
              "PAYOFF_STATEMENT",
              "TERM_SHEET",
              "DEAL_BACKGROUND",
              "OFFERING_MEMORANDUM",
              "LOAN_APPLICATION",
              "SBA_AUTHORIZATION",
              "SBA_GUARANTY",
              "SBA_FORM",
              "SBA_CITIZENSHIP_CERTIFICATION",
              "IRS_FORM_4506C",
              "GOVERNMENT_ID",
              "FRANCHISE_AGREEMENT",
              "EQUITY_INJECTION_VERIFICATION",
              "BENEFICIAL_OWNERSHIP",
              "UCC_SEARCH",
              "UCC_FILING",
              "OFAC_REPORT",
              "CAIVRS_CHECK",
              "SAM_SEARCH",
              "BACKGROUND_SEARCH",
              "LITIGATION_SEARCH",
              "BUSINESS_PLAN",
              "CUSTOM",
              null
            ],
            "description": "With `entity_id`: files it on the entity's open request of this type (and `period_end`). With none, an optional request is created; with several, we choose among them only."
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "With `entity_id` and `data_type`: the period the file covers."
          }
        },
        "required": [
          "upload_id"
        ],
        "description": "One file to file, and where the caller says it belongs (plan D20–D21)."
      },
      "DocumentStatus": {
        "type": "string",
        "enum": [
          "processing",
          "ready",
          "failed"
        ]
      },
      "DocumentUploadResult": {
        "type": "object",
        "properties": {
          "deal_id": {
            "type": "string",
            "pattern": "^clapp_[0-9a-z]+$"
          },
          "files": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/JobFileOutcome"
                }
              ],
              "description": "How each file stood when the job completed."
            },
            "description": "How each file stood when the job completed."
          }
        },
        "required": [
          "deal_id",
          "files"
        ]
      },
      "DocumentsUpload": {
        "type": "object",
        "properties": {
          "upload_ids": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The same, without the per-file detail: up to 50 upload ids to classify and file. Send one of `documents` or `upload_ids`, not both. Every upload is checked against storage as the request comes in; one whose bytes never landed is rejected here rather than failing later inside the job."
          },
          "documents": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/DocumentInput"
                }
              ],
              "description": "One entry per file, up to 50, each saying where it belongs when you know. Placement, from most to least specific: `data_request_id`; `entity_id` + `data_type` (+ `period_end`); `entity_id` alone; nothing, which means we match against the whole deal."
            },
            "description": "One entry per file, up to 50, each saying where it belongs when you know. Placement, from most to least specific: `data_request_id`; `entity_id` + `data_type` (+ `period_end`); `entity_id` alone; nothing, which means we match against the whole deal."
          }
        },
        "description": "`documents[]` (with the party each file belongs to) or the plain `upload_ids[]`."
      },
      "DuplicateOf": {
        "type": "object",
        "properties": {
          "file_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cbfile_[0-9a-z]+$",
            "description": "Null when the original was uploaded in the app before files had ids."
          },
          "document_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdoc_[0-9a-z]+$"
          }
        },
        "required": [
          "file_id",
          "document_id"
        ]
      },
      "Entity": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `asubj_`. The same party on two relationships is one entity."
          },
          "name": {
            "type": "string",
            "description": "Legal name."
          },
          "entity_type": {
            "$ref": "#/components/schemas/EntityType"
          },
          "legal_form": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LegalForm"
              },
              {
                "type": "null"
              }
            ],
            "description": "For a business: its legal form. Null for a person, or when we do not know."
          },
          "tax_identifier_last4": {
            "type": [
              "string",
              "null"
            ],
            "description": "Last four of the EIN or SSN, when we hold one."
          },
          "is_primary": {
            "type": "boolean",
            "description": "Whether this is the relationship's primary party."
          }
        },
        "required": [
          "id",
          "name",
          "entity_type",
          "legal_form",
          "tax_identifier_last4",
          "is_primary"
        ],
        "description": "A party on the relationship — an operating company, a holdco, a guarantor, a trust. Entities are durable: a second deal for the same borrower reuses the entity and everything already analysed for it. Read-only in v1; entities are created by the deal flows."
      },
      "EntityInput": {
        "type": "object",
        "properties": {
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "An existing party, from `GET /relationships/{id}/entities`."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "For a new party: its name. A person's name is first and last."
          },
          "entity_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "BUSINESS",
              "PERSON",
              null
            ],
            "description": "For a new party."
          },
          "legal_form": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "SOLE_PROPRIETORSHIP",
              "PARTNERSHIP",
              "LLC",
              "CORPORATION",
              "NON_PROFIT",
              "TRUST",
              "OTHER",
              null
            ],
            "description": "For a new business: its legal form."
          },
          "role": {
            "type": "string",
            "enum": [
              "BORROWER",
              "GUARANTOR",
              "RELATED"
            ],
            "description": "The party's role on this deal."
          },
          "is_primary": {
            "type": "boolean",
            "description": "The primary party for its role. The first borrower is primary unless another is marked."
          },
          "guarantee": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/GuaranteeInput"
              },
              {
                "type": "null"
              }
            ],
            "description": "For a guarantor: what they guarantee."
          }
        },
        "required": [
          "role"
        ],
        "description": "An existing party by id, or a new one by name and type (D24)."
      },
      "EntityOverride": {
        "type": "object",
        "properties": {
          "parsed_ref": {
            "type": [
              "string",
              "null"
            ],
            "description": "The party's `parsed_ref` from the job's result."
          },
          "parsed_name": {
            "type": [
              "string",
              "null"
            ],
            "description": "Instead of `parsed_ref`, when the name is unambiguous."
          },
          "entity_id": {
            "type": "string",
            "description": "An entity on the relationship."
          }
        },
        "required": [
          "entity_id"
        ],
        "description": "Bind one parsed party to a specific existing entity instead of the one we proposed."
      },
      "EntityType": {
        "type": "string",
        "enum": [
          "BUSINESS",
          "PERSON",
          "OTHER"
        ]
      },
      "Environment": {
        "type": "string",
        "enum": [
          "sandbox",
          "production"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable. Branch on it."
          },
          "message": {
            "type": "string",
            "description": "For a human reading a log."
          },
          "field": {
            "type": "string",
            "description": "The field at fault, as an indexed path (`entities[1].name`), when one is."
          },
          "reason": {
            "type": "string",
            "description": "On `conflict`: why the record refused the change."
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": {}
            },
            "description": "Every failing entry of a batch, with its `field`."
          }
        },
        "required": [
          "code",
          "message"
        ],
        "description": "The one error shape. `code` is stable: branch on it. `message` is for a person reading a log.",
        "additionalProperties": true
      },
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        },
        "required": [
          "error"
        ]
      },
      "EventType": {
        "type": "string",
        "enum": [
          "ORIGINATION",
          "RENEWAL",
          "REVIEW",
          "MODIFICATION",
          "COVENANT_TEST"
        ]
      },
      "Facility": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^cfac_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `cfac_`."
          },
          "title": {
            "type": "string",
            "description": "Facility name, e.g. `Term Loan A`."
          },
          "facility_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FacilityType"
              },
              {
                "type": "null"
              }
            ]
          },
          "commitment_amount": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "The amount committed. Decimal string."
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "The borrowing party. Null means the facility applies to every borrower on the deal."
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the money is for."
          },
          "term_months": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Months to maturity."
          },
          "amortization_months": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Amortization period. Longer than `term_months` means a balloon."
          },
          "interest_only_months": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Interest-only months before amortization starts."
          },
          "rate_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/RateType"
              },
              {
                "type": "null"
              }
            ]
          },
          "interest_rate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "All-in annual rate as a decimal fraction: `\"0.0725\"` is 7.25%."
          },
          "index_name": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/RateIndex"
              },
              {
                "type": "null"
              }
            ],
            "description": "For variable rates."
          },
          "spread_over_index": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Margin over the index, decimal fraction: `\"0.026\"` is 2.60%."
          },
          "rate_floor": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Minimum rate, decimal fraction."
          },
          "rate_ceiling": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Maximum rate, decimal fraction."
          },
          "repayment_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/RepaymentType"
              },
              {
                "type": "null"
              }
            ]
          },
          "payment_amount": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "For `SCHEDULED_PAYMENT`, where the payment is quoted rather than priced from a rate."
          },
          "interest_day_count": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/InterestDayCount"
              },
              {
                "type": "null"
              }
            ],
            "description": "Defaults to your organization's setting."
          },
          "origination_fee": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Decimal fraction: `\"0.01\"` is 1%."
          },
          "prepayment_penalty": {
            "type": [
              "string",
              "null"
            ],
            "description": "Free text, e.g. `3-2-1-0-0`."
          },
          "collateral": {
            "type": [
              "string",
              "null"
            ],
            "description": "What secures it, as stated on the term sheet."
          }
        },
        "required": [
          "id",
          "title",
          "facility_type",
          "commitment_amount",
          "entity_id",
          "purpose",
          "term_months",
          "amortization_months",
          "interest_only_months",
          "rate_type",
          "interest_rate",
          "index_name",
          "spread_over_index",
          "rate_floor",
          "rate_ceiling",
          "repayment_type",
          "payment_amount",
          "interest_day_count",
          "origination_fee",
          "prepayment_penalty",
          "collateral"
        ],
        "description": "One line of credit being asked for — a term loan, a revolver, a CRE mortgage. A deal usually has more than one, and the facilities are the deal's terms: amount, rate, term, repayment and collateral all live here, not on the deal."
      },
      "FacilityInput": {
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "description": "On `PATCH`: the facility to update in place. Omit to add one."
          },
          "title": {
            "type": "string",
            "maxLength": 255,
            "description": "Facility name, e.g. `Term Loan A`."
          },
          "facility_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "CRE_MORTGAGE",
              "TERM_LOAN",
              "LINE_OF_CREDIT",
              "CONSTRUCTION",
              "SBA_7A",
              "SBA_504",
              "SBA_EXPRESS_LINE_OF_CREDIT",
              "SBA_EXPRESS_TERM_LOAN",
              "EQUIPMENT",
              "BRIDGE",
              "AGRICULTURAL",
              "REVOLVING_LINE_OF_CREDIT",
              "LETTER_OF_CREDIT",
              "PARTICIPATION",
              "SALE_LEASEBACK",
              "OPTION_BRIDGE",
              "OTHER",
              null
            ]
          },
          "commitment_amount": {
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "The amount asked for. Decimal string."
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The borrowing party, from the deal's `entities`. Omit when the facility applies to every borrower."
          },
          "purpose": {
            "type": [
              "string",
              "null"
            ],
            "description": "What the money is for."
          },
          "term_months": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Months to maturity."
          },
          "amortization_months": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Amortization period. Longer than `term_months` means a balloon."
          },
          "interest_only_months": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Interest-only months before amortization starts."
          },
          "rate_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "FIXED",
              "VARIABLE",
              "FIXED_TO_FLOAT",
              null
            ]
          },
          "interest_rate": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "All-in annual rate as a decimal fraction: `\"0.0725\"` is 7.25%."
          },
          "index_name": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "PRIME",
              "SOFR",
              "TREASURY_5Y",
              "TREASURY_10Y",
              "FED_FUNDS",
              "OTHER",
              null
            ],
            "description": "For variable rates."
          },
          "spread_over_index": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Margin over the index, decimal fraction: `\"0.026\"` is 2.60%."
          },
          "rate_floor": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Minimum rate, decimal fraction."
          },
          "rate_ceiling": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Maximum rate, decimal fraction."
          },
          "repayment_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "MONTHLY_PI",
              "MONTHLY_IO",
              "QUARTERLY_PI",
              "INTEREST_ONLY",
              "REVOLVING_LINE",
              "SCHEDULED_PAYMENT",
              null
            ]
          },
          "payment_amount": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "For `SCHEDULED_PAYMENT`, where the payment is quoted rather than priced from a rate."
          },
          "interest_day_count": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "ACTUAL_365",
              "ACTUAL_360",
              null
            ],
            "description": "Defaults to your organization's setting."
          },
          "origination_fee": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Decimal fraction: `\"0.01\"` is 1%."
          },
          "prepayment_penalty": {
            "type": [
              "string",
              "null"
            ],
            "description": "Free text, e.g. `3-2-1-0-0`."
          },
          "collateral": {
            "type": [
              "string",
              "null"
            ],
            "description": "What secures it, as stated on the term sheet."
          }
        },
        "required": [
          "title",
          "commitment_amount"
        ],
        "description": "One facility. `title` and `commitment_amount` are required; everything else can be filled in later."
      },
      "FacilityType": {
        "type": "string",
        "enum": [
          "CRE_MORTGAGE",
          "TERM_LOAN",
          "LINE_OF_CREDIT",
          "CONSTRUCTION",
          "SBA_7A",
          "SBA_504",
          "SBA_EXPRESS_LINE_OF_CREDIT",
          "SBA_EXPRESS_TERM_LOAN",
          "EQUIPMENT",
          "BRIDGE",
          "AGRICULTURAL",
          "REVOLVING_LINE_OF_CREDIT",
          "LETTER_OF_CREDIT",
          "PARTICIPATION",
          "SALE_LEASEBACK",
          "OPTION_BRIDGE",
          "OTHER"
        ]
      },
      "Figure": {
        "type": "object",
        "properties": {
          "value": {
            "type": "string",
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Currency to the cent; a ratio as a bare multiple; a percent already scaled."
          },
          "unit": {
            "$ref": "#/components/schemas/FigureUnit"
          },
          "label": {
            "type": "string"
          },
          "as_of": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "period_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "scenario": {
            "type": [
              "string",
              "null"
            ]
          },
          "basis": {
            "type": [
              "string",
              "null"
            ],
            "description": "Which view of the analysis the figure is from (a DSCR worksheet type, say)."
          }
        },
        "required": [
          "value",
          "unit",
          "label",
          "as_of",
          "period_start",
          "period_end",
          "scenario",
          "basis"
        ]
      },
      "FigureUnit": {
        "type": "string",
        "enum": [
          "currency",
          "ratio",
          "percent",
          "count"
        ]
      },
      "File": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^cbfile_[0-9a-z]+$",
            "description": "Aloan's id for the file, prefixed `cbfile_`, from the moment we accept it."
          },
          "deal_id": {
            "type": "string",
            "pattern": "^clapp_[0-9a-z]+$",
            "description": "The deal it was filed on."
          },
          "upload_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^upl_[0-9a-z]+$",
            "description": "The upload it came from. Null for a file uploaded in the app."
          },
          "external_reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your id for the file, echoed back."
          },
          "file_name": {
            "type": "string"
          },
          "file_type": {
            "type": "string",
            "description": "MIME type, as declared."
          },
          "file_size": {
            "type": "integer",
            "description": "Bytes."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/FileStatus"
              }
            ],
            "description": "Where the file is in its lifecycle."
          },
          "placement": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Placement"
              },
              {
                "type": "null"
              }
            ],
            "description": "Where it is filed, or going, and who decided."
          },
          "review": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Review"
              },
              {
                "type": "null"
              }
            ],
            "description": "What a person in the app needs to do, while `awaiting_review`."
          },
          "document_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdoc_[0-9a-z]+$",
            "description": "The filed document, once there is one."
          },
          "duplicate_of": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/DuplicateOf"
              },
              {
                "type": "null"
              }
            ],
            "description": "For a `duplicate`, the file it duplicates."
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileError"
              },
              {
                "type": "null"
              }
            ],
            "description": "For a `failed` file, why."
          },
          "concerns": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Concern"
                }
              ],
              "description": "Disagreements between your placement and the document, and findings about the document. Never silenced by a placement."
            },
            "description": "Disagreements between your placement and the document, and findings about the document. Never silenced by a placement."
          },
          "period_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Once read."
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date",
            "description": "Once read."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The file in the Aloan app's Data tab, for a person to open."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "deal_id",
          "upload_id",
          "external_reference",
          "file_name",
          "file_type",
          "file_size",
          "status",
          "placement",
          "review",
          "document_id",
          "duplicate_of",
          "error",
          "concerns",
          "period_start",
          "period_end",
          "url",
          "created_at",
          "updated_at"
        ],
        "description": "A file you filed on a deal, from the moment we accept it. It has an id before anything has read it, so you can follow it: `queued` → `classifying` → `processing` → `filed`, or `awaiting_review` when a person in Aloan has to decide (`review` says what, with a link), `duplicate` when the same bytes were already on its destination (`duplicate_of` names the original; it is not processed again), `failed` when it could not be filed (`error` says at which stage), `dismissed` when a reviewer set it aside. Read it with `GET /files/{id}`, or find yours by `external_reference` on `GET /deals/{id}/files`."
      },
      "FileError": {
        "type": "object",
        "properties": {
          "code": {
            "$ref": "#/components/schemas/FileErrorCode"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "FileErrorCode": {
        "type": "string",
        "enum": [
          "password_required",
          "classification_failed",
          "processing_failed"
        ]
      },
      "FileOutcome": {
        "type": "string",
        "enum": [
          "filed",
          "needs_review",
          "duplicate",
          "failed"
        ]
      },
      "FileStatus": {
        "type": "string",
        "enum": [
          "queued",
          "classifying",
          "processing",
          "filed",
          "awaiting_review",
          "duplicate",
          "failed",
          "dismissed"
        ]
      },
      "Grid": {
        "type": "object",
        "properties": {
          "columns": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GridColumn"
            }
          },
          "rows": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GridRow"
            }
          }
        },
        "required": [
          "columns",
          "rows"
        ]
      },
      "GridColumn": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable within the table; the key of each row's `values`."
          },
          "label": {
            "type": "string"
          },
          "period_start": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "kind": {
            "allOf": [
              {
                "$ref": "#/components/schemas/GridColumnKind"
              }
            ],
            "description": "`percent` is the common-size column beside a period."
          },
          "scenario": {
            "type": [
              "string",
              "null"
            ]
          },
          "basis": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/GridColumnBasis"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "type": [
              "string",
              "null"
            ],
            "description": "The owner on a split personal statement, or the source of one of two readings of a year."
          }
        },
        "required": [
          "key",
          "label",
          "period_start",
          "period_end",
          "kind",
          "scenario",
          "basis",
          "source"
        ]
      },
      "GridColumnBasis": {
        "type": "string",
        "enum": [
          "actual",
          "projected"
        ]
      },
      "GridColumnKind": {
        "type": "string",
        "enum": [
          "value",
          "percent"
        ]
      },
      "GridRow": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "Stable within the table (a metric key, a category group)."
          },
          "label": {
            "type": "string"
          },
          "depth": {
            "type": "integer",
            "description": "Indent under the line above."
          },
          "kind": {
            "$ref": "#/components/schemas/GridRowKind"
          },
          "unit": {
            "allOf": [
              {
                "$ref": "#/components/schemas/GridRowUnit"
              }
            ],
            "description": "How to read `values`."
          },
          "values": {
            "type": "object",
            "additionalProperties": {},
            "description": "By column key: a decimal string, the text the table holds, or null."
          }
        },
        "required": [
          "key",
          "label",
          "depth",
          "kind",
          "unit",
          "values"
        ]
      },
      "GridRowKind": {
        "type": "string",
        "enum": [
          "line",
          "subtotal",
          "total",
          "ratio",
          "section"
        ]
      },
      "GridRowUnit": {
        "type": "string",
        "enum": [
          "currency",
          "percent",
          "ratio",
          "count",
          "text"
        ]
      },
      "Guarantee": {
        "type": "object",
        "properties": {
          "type": {
            "$ref": "#/components/schemas/GuaranteeType"
          },
          "cap": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "For a `LIMITED` guarantee, the cap. Decimal string."
          }
        },
        "required": [
          "type",
          "cap"
        ]
      },
      "GuaranteeInput": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "UNLIMITED",
              "LIMITED",
              "CORPORATE"
            ],
            "description": "`UNLIMITED`, `LIMITED` or `CORPORATE`."
          },
          "cap": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "For a `LIMITED` guarantee, the cap. Decimal string."
          }
        },
        "required": [
          "type"
        ],
        "description": "The guarantee a guarantor gives."
      },
      "GuaranteeType": {
        "type": "string",
        "enum": [
          "UNLIMITED",
          "LIMITED",
          "CORPORATE"
        ]
      },
      "IntakeConfirm": {
        "type": "object",
        "properties": {
          "entity_overrides": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/EntityOverride"
                }
              ],
              "description": "Parties to bind to a specific existing entity instead of the one we proposed."
            },
            "description": "Parties to bind to a specific existing entity instead of the one we proposed."
          }
        },
        "description": "Accept the parsed result, overriding any proposed entity match."
      },
      "IntakeCreate": {
        "type": "object",
        "properties": {
          "relationship_id": {
            "type": "string",
            "description": "Aloan id, or `external:<your id>`."
          },
          "upload_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The term sheet, uploaded first — see Uploads."
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 8000,
            "description": "Alternative to `upload_id`: the deal in prose, up to 8,000 characters."
          },
          "assigned_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the deal owner."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Your id for the deal this will create."
          },
          "event_type": {
            "type": "string",
            "enum": [
              "ORIGINATION",
              "RENEWAL",
              "REVIEW",
              "MODIFICATION",
              "COVENANT_TEST"
            ],
            "description": "`ORIGINATION` (default), `RENEWAL`, `REVIEW`, `MODIFICATION`."
          }
        },
        "required": [
          "relationship_id"
        ],
        "description": "A term sheet to read, or the deal in prose."
      },
      "IntakeParty": {
        "type": "object",
        "properties": {
          "parsed_ref": {
            "type": "string",
            "description": "The stable handle a confirm override names."
          },
          "parsed_name": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/ParsedRole"
          },
          "entity_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EntityType"
              },
              {
                "type": "null"
              }
            ]
          },
          "legal_form": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LegalForm"
              },
              {
                "type": "null"
              }
            ]
          },
          "proposed_entity_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "The existing entity we propose to reuse."
          },
          "confidence": {
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "parsed_ref",
          "parsed_name",
          "role",
          "entity_type",
          "legal_form",
          "proposed_entity_id",
          "confidence"
        ]
      },
      "IntakeResult": {
        "type": "object",
        "properties": {
          "relationship_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^crel_[0-9a-z]+$"
          },
          "parties": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IntakeParty"
            }
          },
          "terms": {
            "type": "array",
            "items": {},
            "description": "The loan request(s) as the parser read them."
          },
          "deal_id": {
            "type": "string",
            "pattern": "^clapp_[0-9a-z]+$",
            "description": "Once confirmed."
          }
        },
        "required": [
          "relationship_id",
          "parties",
          "terms"
        ]
      },
      "InterestDayCount": {
        "type": "string",
        "enum": [
          "ACTUAL_365",
          "ACTUAL_360"
        ]
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^job_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `job_`."
          },
          "type": {
            "$ref": "#/components/schemas/JobType"
          },
          "status": {
            "$ref": "#/components/schemas/JobStatus"
          },
          "progress": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/JobProgress"
              },
              {
                "type": "null"
              }
            ],
            "description": "For a document upload while `processing`."
          },
          "summary": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/JobSummary"
              },
              {
                "type": "null"
              }
            ],
            "description": "For a completed document upload."
          },
          "result": {
            "anyOf": [
              {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/DocumentUploadResult"
                  },
                  {
                    "$ref": "#/components/schemas/IntakeResult"
                  }
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Populated on a terminal success, or at `awaiting_confirmation`. Shape depends on `type`."
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/JobError"
              },
              {
                "type": "null"
              }
            ],
            "description": "Populated on failure."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "Moves when the work behind the job does."
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        },
        "required": [
          "id",
          "type",
          "status",
          "progress",
          "summary",
          "result",
          "error",
          "created_at",
          "updated_at",
          "completed_at"
        ],
        "description": "A unit of work that outlives its request — parsing a term sheet, processing an upload. Every asynchronous operation returns one, and you poll it until it reaches a terminal state."
      },
      "JobError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      },
      "JobFileOutcome": {
        "type": "object",
        "properties": {
          "file_id": {
            "type": "string",
            "pattern": "^cbfile_[0-9a-z]+$"
          },
          "upload_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^upl_[0-9a-z]+$"
          },
          "external_reference": {
            "type": [
              "string",
              "null"
            ]
          },
          "file_name": {
            "type": "string"
          },
          "outcome": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileOutcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "document_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdoc_[0-9a-z]+$"
          },
          "data_request_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdr_[0-9a-z]+$"
          },
          "error": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/FileError"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "file_id",
          "upload_id",
          "external_reference",
          "file_name",
          "outcome",
          "document_id",
          "data_request_id",
          "error"
        ]
      },
      "JobProgress": {
        "type": "object",
        "properties": {
          "total": {
            "type": "integer"
          },
          "settled": {
            "type": "integer",
            "description": "Files that need nothing more from us."
          }
        },
        "required": [
          "total",
          "settled"
        ]
      },
      "JobStatus": {
        "type": "string",
        "enum": [
          "processing",
          "awaiting_confirmation",
          "completed",
          "failed",
          "cancelled"
        ]
      },
      "JobSummary": {
        "type": "object",
        "properties": {
          "filed": {
            "type": "integer"
          },
          "needs_review": {
            "type": "integer"
          },
          "duplicate": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          }
        },
        "required": [
          "filed",
          "needs_review",
          "duplicate",
          "failed"
        ]
      },
      "JobType": {
        "type": "string",
        "enum": [
          "document_upload",
          "deal_intake"
        ]
      },
      "LegalForm": {
        "type": "string",
        "enum": [
          "SOLE_PROPRIETORSHIP",
          "PARTNERSHIP",
          "LLC",
          "CORPORATION",
          "NON_PROFIT",
          "TRUST",
          "OTHER"
        ]
      },
      "ListOrder": {
        "type": "string",
        "enum": [
          "updated_at",
          "-updated_at",
          "-created_at"
        ]
      },
      "Loan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^cloan_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `cloan_`."
          },
          "external_loan_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The bank's loan number, as the bank writes it."
          },
          "status": {
            "$ref": "#/components/schemas/LoanStatus"
          },
          "origination_date": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "commitment_amount": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^-?\\d+(\\.\\d+)?$",
            "description": "Sum of the agreement's notes. Decimal string."
          },
          "note_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "pattern": "^cfac_[0-9a-z]+$"
            },
            "description": "The notes (booked facilities) this agreement covers: what `note_ids` on `POST /deals` takes."
          },
          "originating_deal_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^clapp_[0-9a-z]+$",
            "description": "The deal that booked it, when it was booked here."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "external_loan_id",
          "status",
          "origination_date",
          "commitment_amount",
          "note_ids",
          "originating_deal_id",
          "created_at",
          "updated_at"
        ],
        "description": "A booked credit agreement on the relationship and the notes it covers. A renewal, review or modification acts on notes; pass them as `note_ids` on `POST /deals`. Read-only in v1; agreements are booked when a deal funds."
      },
      "LoanStatus": {
        "type": "string",
        "enum": [
          "ACTIVE",
          "PAID_OFF",
          "MATURED",
          "DEFAULTED"
        ]
      },
      "LoanTypeOption": {
        "type": "object",
        "properties": {
          "key": {
            "type": "string",
            "description": "What `loan_type` takes."
          },
          "label": {
            "type": "string"
          }
        },
        "required": [
          "key",
          "label"
        ]
      },
      "Me": {
        "type": "object",
        "properties": {
          "organization": {
            "$ref": "#/components/schemas/Organization"
          },
          "scope": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Scope"
              }
            ],
            "description": "What the key may do."
          },
          "environment": {
            "$ref": "#/components/schemas/Environment"
          },
          "key_prefix": {
            "type": "string",
            "description": "The start of the key, enough to recognize it."
          }
        },
        "required": [
          "organization",
          "scope",
          "environment",
          "key_prefix"
        ]
      },
      "MemoDate": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string",
            "description": "`Prepared`, `Submitted`, `Approved` or `Declined`."
          },
          "date": {
            "type": "string",
            "format": "date"
          }
        },
        "required": [
          "label",
          "date"
        ]
      },
      "MemoDocument": {
        "type": "object",
        "properties": {
          "title": {
            "type": "string"
          },
          "subtitle_lines": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "logo": {
            "type": [
              "string",
              "null"
            ],
            "description": "A data URI, when the lender has a logo."
          },
          "nodes": {
            "type": "array",
            "items": {},
            "description": "Headings, paragraphs and tables, in order: the same nodes the Word file is built from."
          }
        },
        "required": [
          "title",
          "subtitle_lines",
          "logo",
          "nodes"
        ]
      },
      "MemoDownloadFormat": {
        "type": "string",
        "enum": [
          "json",
          "docx"
        ]
      },
      "Organization": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^org_[0-9a-z]+$"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name"
        ]
      },
      "ParsedRole": {
        "type": "string",
        "enum": [
          "BORROWER",
          "GUARANTOR",
          "RELATED",
          "OWNER"
        ]
      },
      "Party": {
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$",
            "description": "The entity. Null only for a party we cannot address yet; `warnings` says so."
          },
          "name": {
            "type": "string",
            "description": "The party's name."
          },
          "entity_type": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/EntityType"
              },
              {
                "type": "null"
              }
            ]
          },
          "legal_form": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/LegalForm"
              },
              {
                "type": "null"
              }
            ],
            "description": "As on the Entity object. Null for a person."
          },
          "role": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PartyRole"
              },
              {
                "type": "null"
              }
            ],
            "description": "`BORROWER`, `GUARANTOR` or `RELATED`, which you can set; `TARGET`, `COLLATERAL` and `SELLER`, which only the app sets. Null for a party with no role on the deal."
          },
          "is_primary": {
            "type": "boolean",
            "description": "Whether this is the primary party for its role."
          },
          "is_collateral": {
            "type": "boolean",
            "description": "Whether the party also serves as collateral."
          },
          "guarantee": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Guarantee"
              },
              {
                "type": "null"
              }
            ],
            "description": "The guarantee this party gives, if any."
          },
          "warnings": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Warning"
                }
              ],
              "description": "Problems with this party, such as `entity_unmapped`."
            },
            "description": "Problems with this party, such as `entity_unmapped`."
          }
        },
        "required": [
          "id",
          "name",
          "entity_type",
          "legal_form",
          "role",
          "is_primary",
          "is_collateral",
          "guarantee",
          "warnings"
        ],
        "description": "A party on a deal: the durable entity it points at, its role here, and what it gives."
      },
      "PartyRole": {
        "type": "string",
        "enum": [
          "BORROWER",
          "GUARANTOR",
          "RELATED",
          "TARGET",
          "COLLATERAL",
          "SELLER"
        ]
      },
      "Placement": {
        "type": "object",
        "properties": {
          "data_request_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdr_[0-9a-z]+$"
          },
          "entity_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^asubj_[0-9a-z]+$"
          },
          "data_type": {
            "type": [
              "string",
              "null"
            ],
            "description": "e.g. `BUSINESS_TAX_RETURN`."
          },
          "period_end": {
            "type": [
              "string",
              "null"
            ],
            "format": "date"
          },
          "source": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PlacementSource"
              }
            ],
            "description": "Who decided: you, the matcher, or a person in the app."
          }
        },
        "required": [
          "data_request_id",
          "entity_id",
          "data_type",
          "period_end",
          "source"
        ]
      },
      "PlacementSource": {
        "type": "string",
        "enum": [
          "caller",
          "matcher",
          "reviewer"
        ]
      },
      "Question": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^cdq_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `cdq_`."
          },
          "kind": {
            "$ref": "#/components/schemas/QuestionKind"
          },
          "status": {
            "$ref": "#/components/schemas/QuestionStatus"
          },
          "prompt": {
            "type": "string",
            "description": "The question, as your team sees it."
          },
          "why": {
            "type": [
              "string",
              "null"
            ],
            "description": "One line of context."
          },
          "file_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cbfile_[0-9a-z]+$",
            "description": "The file it is about."
          },
          "document_id": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^cdoc_[0-9a-z]+$",
            "description": "The document, once the file is filed."
          },
          "suggestions": {
            "type": "array",
            "items": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/Suggestion"
                }
              ],
              "description": "The answers the app offers."
            },
            "description": "The answers the app offers."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Opens the question in the Aloan app."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "answered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "kind",
          "status",
          "prompt",
          "why",
          "file_id",
          "document_id",
          "suggestions",
          "url",
          "created_at",
          "answered_at",
          "updated_at"
        ],
        "description": "Something a person in Aloan has to decide about a file: is \"BV Holdings\" the same company as Brookvale Holdings LLC? Read-only in v1 — `url` opens it in the app, where it is answered in one click. The file it is about is `file_id`."
      },
      "QuestionKind": {
        "type": "string",
        "enum": [
          "IDENTITY_LINK",
          "NEW_ENTITY",
          "WRONG_DEAL",
          "DOC_CONVENTION"
        ]
      },
      "QuestionStatus": {
        "type": "string",
        "enum": [
          "OPEN",
          "ANSWERED",
          "DEFERRED"
        ]
      },
      "RateIndex": {
        "type": "string",
        "enum": [
          "PRIME",
          "SOFR",
          "TREASURY_5Y",
          "TREASURY_10Y",
          "FED_FUNDS",
          "OTHER"
        ]
      },
      "RateType": {
        "type": "string",
        "enum": [
          "FIXED",
          "VARIABLE",
          "FIXED_TO_FLOAT"
        ]
      },
      "Relationship": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^crel_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `crel_`."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your id for this relationship. Unique within your organization."
          },
          "display_name": {
            "type": "string",
            "description": "What the relationship is called."
          },
          "status": {
            "$ref": "#/components/schemas/RelationshipStatus"
          },
          "relationship_manager": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the owning RM."
          },
          "fiscal_year_end_month": {
            "type": [
              "integer",
              "null"
            ],
            "description": "1–12. Defaults to 12."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The relationship in the Aloan app, for a person to open."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339, UTC. Sort key for `updated_after`."
          }
        },
        "required": [
          "id",
          "external_id",
          "display_name",
          "status",
          "relationship_manager",
          "fiscal_year_end_month",
          "url",
          "created_at",
          "updated_at"
        ],
        "description": "The borrowing relationship — the durable home for a borrower and everyone around them. The analogue of a CIF or a Salesforce account, and the parent of every deal you create."
      },
      "RelationshipCreate": {
        "type": "object",
        "properties": {
          "display_name": {
            "type": "string",
            "maxLength": 255,
            "description": "What the relationship is called."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Your id for it. Must be unique within your organization."
          },
          "relationship_manager": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Email of the owning RM. Must be a user in your organization."
          },
          "fiscal_year_end_month": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "description": "1–12. Defaults to 12."
          }
        },
        "required": [
          "display_name"
        ],
        "description": "A new relationship."
      },
      "RelationshipStatus": {
        "type": "string",
        "enum": [
          "ACTIVE",
          "EXITED",
          "PROSPECT"
        ]
      },
      "RelationshipUpdate": {
        "type": "object",
        "properties": {
          "display_name": {
            "type": "string",
            "maxLength": 255,
            "description": "Rename the relationship."
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "description": "Claim it with your id while it has none; `null` clears it. A record that already carries another of your ids answers `409 conflict` with `reason: external_id_already_set` — clear it first to re-point it."
          },
          "relationship_manager": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "description": "Reassign the owning RM."
          },
          "fiscal_year_end_month": {
            "type": "integer",
            "minimum": 1,
            "maximum": 12,
            "description": "1–12."
          }
        },
        "description": "Fields to change. Send only what moves."
      },
      "RepaymentType": {
        "type": "string",
        "enum": [
          "MONTHLY_PI",
          "MONTHLY_IO",
          "QUARTERLY_PI",
          "INTEREST_ONLY",
          "REVOLVING_LINE",
          "SCHEDULED_PAYMENT"
        ]
      },
      "Review": {
        "type": "object",
        "properties": {
          "kind": {
            "$ref": "#/components/schemas/ReviewKind"
          },
          "id": {
            "type": "string",
            "description": "The question (`cdq_`) or review-queue item (`cumd_`)."
          },
          "prompt": {
            "type": [
              "string",
              "null"
            ],
            "description": "The question your team is asked, when it is one."
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "Opens it in the Aloan app."
          }
        },
        "required": [
          "kind",
          "id",
          "prompt",
          "url"
        ]
      },
      "ReviewKind": {
        "type": "string",
        "enum": [
          "question",
          "unmatched"
        ]
      },
      "Scope": {
        "type": "string",
        "enum": [
          "read",
          "read_write"
        ]
      },
      "Suggestion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "label": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "label"
        ]
      },
      "Upload": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^upl_[0-9a-z]+$",
            "description": "Aloan's id, prefixed `upl_`. This is what you reference once the bytes are up."
          },
          "upload_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Pre-authorized URL to `PUT` the bytes to. Valid until `expires_at`."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "The URL stops working here. Miss it and ask for another with `POST /uploads/{id}/url`; the upload id stays valid."
          },
          "status": {
            "allOf": [
              {
                "$ref": "#/components/schemas/UploadStatus"
              }
            ],
            "description": "`awaiting_bytes` until we check storage and find your file, then `ready`; `expired` after 24 hours unreferenced."
          }
        },
        "required": [
          "id",
          "upload_url",
          "expires_at",
          "status"
        ],
        "description": "A file on its way in. You declare it, put the bytes straight into our storage with the URL we hand back, then reference the upload wherever a file is wanted — a term sheet on a deal, documents on a deal. Bytes never pass through the API."
      },
      "UploadCreate": {
        "type": "object",
        "properties": {
          "file_name": {
            "type": "string",
            "maxLength": 500,
            "description": "Name as you hold it. Kept on the document."
          },
          "file_type": {
            "type": "string",
            "enum": [
              "application/msword",
              "application/pdf",
              "application/vnd.ms-excel",
              "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
              "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
              "image/gif",
              "image/jpeg",
              "image/png",
              "image/tiff",
              "image/webp",
              "text/csv"
            ],
            "description": "MIME type. PDF, DOCX, XLSX, XLS, CSV, DOC, JPEG, PNG, GIF, WEBP or TIFF."
          },
          "file_size": {
            "type": "integer",
            "minimum": 1,
            "maximum": 104857600,
            "description": "Size in bytes. 100 MB maximum."
          }
        },
        "required": [
          "file_name",
          "file_type",
          "file_size"
        ],
        "description": "A file to declare."
      },
      "UploadStatus": {
        "type": "string",
        "enum": [
          "awaiting_bytes",
          "ready",
          "expired"
        ]
      },
      "User": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "role": {
            "$ref": "#/components/schemas/UserRole"
          },
          "assignable": {
            "type": "boolean",
            "description": "Whether `assigned_to` and `relationship_manager` can name this user."
          }
        },
        "required": [
          "email",
          "name",
          "role",
          "assignable"
        ]
      },
      "UserRole": {
        "type": "string",
        "enum": [
          "ADMIN",
          "UNDERWRITER",
          "MEMBER",
          "RELATIONSHIP_MANAGER",
          "VIEWER",
          "IT_ADMIN"
        ]
      },
      "Warning": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "`entity_unmapped`: the party has no durable entity yet."
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "code",
          "message"
        ]
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your API key."
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "x-aloan-errors": [
    {
      "code": "unauthorized",
      "status": 401,
      "meaning": "Missing, malformed, revoked or expired API key."
    },
    {
      "code": "insufficient_scope",
      "status": 403,
      "meaning": "A read-only key attempted a write."
    },
    {
      "code": "forbidden",
      "status": 403,
      "meaning": "The key's organization may not access this record."
    },
    {
      "code": "ip_not_allowed",
      "status": 403,
      "meaning": "Your organization limits API access to an IP allowlist (Settings → Security) and this request came from outside it. `ip` is the address we saw."
    },
    {
      "code": "not_found",
      "status": 404,
      "meaning": "No such record, or it belongs to another organization."
    },
    {
      "code": "method_not_allowed",
      "status": 405,
      "meaning": "The path exists but not for this method."
    },
    {
      "code": "invalid_request",
      "status": 400,
      "meaning": "The request was malformed. `field` names the offender when one does."
    },
    {
      "code": "validation_failed",
      "status": 422,
      "meaning": "Well-formed, but rejected by a business rule — an unknown assignee, say."
    },
    {
      "code": "placement_conflict",
      "status": 422,
      "meaning": "A file's placement contradicts the deal (a closed request, another entity's request, a type or period the request is not for). `details[]` lists each offending entry by index; nothing was consumed."
    },
    {
      "code": "conflict",
      "status": 409,
      "meaning": "The record is not in a state that permits this operation, or an `external_id` is already in use. `reason` says which; the message names the existing record."
    },
    {
      "code": "idempotency_key_reused",
      "status": 409,
      "meaning": "The `Idempotency-Key` was already used for a request with a different body."
    },
    {
      "code": "request_in_progress",
      "status": 409,
      "meaning": "A request with this `Idempotency-Key` is still in flight. Retry once it completes."
    },
    {
      "code": "unsupported_media_type",
      "status": 415,
      "meaning": "Send JSON."
    },
    {
      "code": "rate_limited",
      "status": 429,
      "meaning": "Rate limit exceeded. `Retry-After` gives the seconds to wait."
    },
    {
      "code": "server_error",
      "status": 500,
      "meaning": "Our fault. Retry a read freely; before retrying a create, check whether it took effect (list by `external_id`)."
    }
  ],
  "x-aloan-figures": [
    {
      "key": "net_worth",
      "label": "Net Worth",
      "unit": "currency",
      "meaning": "Total assets less total liabilities on a published balance sheet. NOT the equity section — on an unbalanced sheet the two differ, and this is the figure a lender underwrites. For a personal statement it is the bottom line; contingent liabilities are excluded, as the statement excludes them.",
      "published_by": [
        "combined_balance_sheet",
        "combined_personal_balance_sheet"
      ]
    },
    {
      "key": "total_assets",
      "label": "Total Assets",
      "unit": "currency",
      "meaning": "Every asset-side line on a published balance sheet, after contra lines. Excludes anything the statement discloses beside the sheet rather than on it.",
      "published_by": [
        "combined_balance_sheet",
        "combined_personal_balance_sheet"
      ]
    },
    {
      "key": "total_liabilities",
      "label": "Total Liabilities",
      "unit": "currency",
      "meaning": "Every liability-side line on a published balance sheet. Excludes contingent liabilities, which are not owed today and are disclosed beside the sheet.",
      "published_by": [
        "combined_balance_sheet",
        "combined_personal_balance_sheet"
      ]
    },
    {
      "key": "dscr",
      "label": "DSCR",
      "unit": "ratio",
      "meaning": "The coverage ratio the published DSCR analysis prints, in its latest historical column: cash available for debt service over debt service. A bare multiple (1.42 is 1.42x). The worksheet type, carried as the figure's basis, says whose coverage it is (business, personal, global).",
      "published_by": [
        "dscr_analysis"
      ]
    },
    {
      "key": "available_cash_flow",
      "label": "Cash Available for Debt Service",
      "unit": "currency",
      "meaning": "The cash the DSCR divides, in the same column: the row that, over total_debt_service, gives the printed ratio. Published only when the worksheet's own figures prove it.",
      "published_by": [
        "dscr_analysis"
      ]
    },
    {
      "key": "total_debt_service",
      "label": "Total Debt Service",
      "unit": "currency",
      "meaning": "The annual debt service the DSCR divides by, in the same column. Published only when the worksheet's own figures prove it.",
      "published_by": [
        "dscr_analysis"
      ]
    }
  ],
  "x-aloan-id-prefixes": [
    {
      "prefix": "crel_",
      "object": "Relationship"
    },
    {
      "prefix": "asubj_",
      "object": "Entity"
    },
    {
      "prefix": "upl_",
      "object": "Upload"
    },
    {
      "prefix": "clapp_",
      "object": "Deal"
    },
    {
      "prefix": "cfac_",
      "object": "Facility"
    },
    {
      "prefix": "cloan_",
      "object": "Loan"
    },
    {
      "prefix": "cdr_",
      "object": "Data request"
    },
    {
      "prefix": "cbfile_",
      "object": "File"
    },
    {
      "prefix": "cdoc_",
      "object": "Document"
    },
    {
      "prefix": "cdq_",
      "object": "Question"
    },
    {
      "prefix": "canalysis_",
      "object": "Analysis"
    },
    {
      "prefix": "job_",
      "object": "Job"
    }
  ]
}
