{
  "openapi": "3.1.0",
  "info": {
    "title": "BuiltCRM Public API",
    "version": "1.0.0",
    "summary": "Customers, jobs, availability, estimates and invoices for Zapier, Make and custom tools.",
    "description": "Human-readable reference: https://builtcrm.app/docs/api. All JSON. Times are ISO 8601 in UTC unless a field says it is local. Rate limit: 60 requests per minute per key (rolling 60-second window); over the limit returns 429 rate_limited with Retry-After: 60. Never put an API key in website or browser code; call the API only from your server or an automation tool.",
    "contact": {
      "name": "BuiltCRM",
      "email": "hello@builtcrm.app",
      "url": "https://builtcrm.app/contact"
    }
  },
  "servers": [
    {
      "url": "https://crm.yourcompany.com/api/v1",
      "description": "Each BuiltCRM install runs on the client's own domain."
    }
  ],
  "externalDocs": {
    "description": "BuiltCRM API Reference",
    "url": "https://builtcrm.app/docs/api"
  },
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyHeader": []
    }
  ],
  "tags": [
    {
      "name": "Keys"
    },
    {
      "name": "Customers"
    },
    {
      "name": "Jobs"
    },
    {
      "name": "Estimates"
    },
    {
      "name": "Invoices"
    }
  ],
  "paths": {
    "/me": {
      "get": {
        "operationId": "getMe",
        "tags": [
          "Keys"
        ],
        "summary": "Check an API key",
        "description": "Scope: any valid key. Returns the key name and its scopes.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "any",
        "responses": {
          "200": {
            "description": "Key info",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "key_name": {
                          "type": "string"
                        },
                        "scopes": {
                          "type": "array",
                          "items": {
                            "$ref": "#/components/schemas/Scope"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/customers": {
      "get": {
        "operationId": "listCustomers",
        "tags": [
          "Customers"
        ],
        "summary": "List or search customers",
        "description": "Scope: customers:read. Newest first.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "phone",
            "in": "query",
            "required": false,
            "description": "Matches the last 10 digits against all of the customer's phones (formatting ignored; at least 7 digits)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "email",
            "in": "query",
            "required": false,
            "description": "Exact match, case-insensitive",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "name",
            "in": "query",
            "required": false,
            "description": "Partial match",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Partial match on name, email, address or phone",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Customers",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "count"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Customer"
                      }
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Create a customer",
        "description": "Scope: customers:write. Returns 201. Returns 409 duplicate_customer if the phone already belongs to a customer.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "customers:write",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    },
                    "created_by": {
                      "type": "string",
                      "examples": [
                        "API · Zapier"
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_json, validation_error or invalid_phone",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "duplicate_customer",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/customers/{id}": {
      "get": {
        "operationId": "getCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Get a customer",
        "description": "Scope: customers:read.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "customers:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Customer",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "patch": {
        "operationId": "updateCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Update a customer",
        "description": "Scope: customers:write. Send at least one field. Changes are logged on the customer's most recent job.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "customers:write",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CustomerUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Customer"
                    },
                    "changes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_json, validation_error, invalid_id, invalid_phone or invalid_update",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "phone_in_use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/jobs": {
      "get": {
        "operationId": "listJobs",
        "tags": [
          "Jobs"
        ],
        "summary": "List jobs",
        "description": "Scope: jobs:read. Newest first.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "jobs:read",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Comma list of new, scheduled, in_progress, completed, cancelled",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "Customer UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "technician_id",
            "in": "query",
            "required": false,
            "description": "Lead technician UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "job_number",
            "in": "query",
            "required": false,
            "description": "Exact",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scheduled_from",
            "in": "query",
            "required": false,
            "description": "ISO 8601 start of range on scheduled_at",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "scheduled_to",
            "in": "query",
            "required": false,
            "description": "ISO 8601 end of range on scheduled_at",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Jobs",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "count"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Job"
                      }
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_status, invalid_id or invalid_date",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "createJob",
        "tags": [
          "Jobs"
        ],
        "summary": "Create a job",
        "description": "Scope: jobs:create. Returns 201. Omit scheduled_at to create an unscheduled new job. Scheduling errors: missing_zip, zip_not_serviced, invalid_technician (400); outside_business_hours, lead_time_violation, window_full, fully_booked, no_technician_working_this_day, technician_not_covering_zip, technician_not_working_this_day, technician_window_full (409).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "jobs:create",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobMutationResult"
                }
              }
            }
          },
          "400": {
            "description": "invalid_json, validation_error, invalid_date or scheduling error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "customer_not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Scheduling conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{id}": {
      "get": {
        "operationId": "getJob",
        "tags": [
          "Jobs"
        ],
        "summary": "Get a job",
        "description": "Scope: jobs:read.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "jobs:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Job"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/availability": {
      "get": {
        "operationId": "getAvailability",
        "tags": [
          "Jobs"
        ],
        "summary": "List open arrival windows",
        "description": "Scope: jobs:read. Send date and either zip or address. Pass a window's start as scheduled_at when creating or rescheduling a job.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "jobs:read",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "description": "YYYY-MM-DD",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "zip",
            "in": "query",
            "required": false,
            "description": "5-digit ZIP (one of zip or address)",
            "schema": {
              "type": "string",
              "pattern": "^\\d{5}$"
            }
          },
          {
            "name": "address",
            "in": "query",
            "required": false,
            "description": "Address containing a ZIP (one of zip or address)",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Availability",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Availability"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_date, missing_zip or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{id_or_job_number}/reschedule": {
      "post": {
        "operationId": "rescheduleJob",
        "tags": [
          "Jobs"
        ],
        "summary": "Reschedule a job",
        "description": "Scope: jobs:reschedule. Strict scheduling rules. Errors also include already_cancelled, already_completed, multi_technician_job, phone_mismatch and missing_zip, zip_not_serviced, invalid_technician (400); outside_business_hours, lead_time_violation, window_full, fully_booked, no_technician_working_this_day, technician_not_covering_zip, technician_not_working_this_day, technician_window_full (409).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "jobs:reschedule",
        "parameters": [
          {
            "name": "id_or_job_number",
            "in": "path",
            "required": true,
            "description": "Job UUID or job number",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RescheduleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rescheduled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RescheduleResult"
                }
              }
            }
          },
          "400": {
            "description": "invalid_json, validation_error, invalid_date or scheduling error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope or phone_mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Scheduling conflict, already_cancelled, already_completed or multi_technician_job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/jobs/{id_or_job_number}/cancel": {
      "post": {
        "operationId": "cancelJob",
        "tags": [
          "Jobs"
        ],
        "summary": "Cancel a job",
        "description": "Scope: jobs:cancel. The body is optional.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "jobs:cancel",
        "parameters": [
          {
            "name": "id_or_job_number",
            "in": "path",
            "required": true,
            "description": "Job UUID or job number",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CancelRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobMutationResult"
                }
              }
            }
          },
          "400": {
            "description": "invalid_json or validation_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope or phone_mismatch",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "already_cancelled, already_completed or multi_technician_job",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/estimates": {
      "get": {
        "operationId": "listEstimates",
        "tags": [
          "Estimates"
        ],
        "summary": "List estimates",
        "description": "Scope: estimates:read. Internal part numbers and part links are always removed from line_items. POST returns 405 method_not_allowed (not supported yet).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "estimates:read",
        "parameters": [
          {
            "name": "job_id",
            "in": "query",
            "required": false,
            "description": "Job UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Comma list, e.g. draft,sent,approved",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "doc_number",
            "in": "query",
            "required": false,
            "description": "Exact",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Estimates",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "count"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Estimate"
                      }
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/estimates/{id}": {
      "get": {
        "operationId": "getEstimate",
        "tags": [
          "Estimates"
        ],
        "summary": "Get an estimate",
        "description": "Scope: estimates:read.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "estimates:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Estimate",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Estimate"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/invoices": {
      "get": {
        "operationId": "listInvoices",
        "tags": [
          "Invoices"
        ],
        "summary": "List invoices",
        "description": "Scope: invoices:read. Internal part numbers and part links are always removed from line_items. POST returns 405 method_not_allowed (not supported yet).",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "job_id",
            "in": "query",
            "required": false,
            "description": "Job UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Comma list, e.g. draft,sent,paid,void",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "doc_number",
            "in": "query",
            "required": false,
            "description": "Exact",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/offset"
          }
        ],
        "responses": {
          "200": {
            "description": "Invoices",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data",
                    "count"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Invoice"
                      }
                    },
                    "count": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_query",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/invoices/{id}": {
      "get": {
        "operationId": "getInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Get an invoice",
        "description": "Scope: invoices:read.",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "apiKeyHeader": []
          }
        ],
        "x-required-scope": "invoices:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Record UUID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Invoice",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Invoice"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "invalid_id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "missing_api_key, invalid_api_key or revoked_api_key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "insufficient_scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "not_found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "rate_limited: over 60 requests per minute",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer",
                  "const": 60
                }
              }
            }
          },
          "500": {
            "description": "internal_error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer <key>. Keys use the td_ prefix followed by 48 hex characters."
      },
      "apiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Same key, sent in the x-api-key header."
      }
    },
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "description": "Page size",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 50
        }
      },
      "offset": {
        "name": "offset",
        "in": "query",
        "description": "Records to skip",
        "schema": {
          "type": "integer",
          "minimum": 0,
          "default": 0
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "code"
        ],
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable message"
          },
          "code": {
            "type": "string",
            "description": "Machine code"
          }
        }
      },
      "Scope": {
        "type": "string",
        "enum": [
          "customers:read",
          "customers:write",
          "jobs:read",
          "jobs:create",
          "jobs:reschedule",
          "jobs:cancel",
          "estimates:read",
          "estimates:create",
          "invoices:read",
          "invoices:create"
        ],
        "description": "estimates:create and invoices:create are not available yet."
      },
      "PhoneType": {
        "type": "string",
        "enum": [
          "cell",
          "home",
          "alternative"
        ]
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "client_phones": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "$ref": "#/components/schemas/PhoneType"
                },
                "phone_number": {
                  "type": "string"
                },
                "is_primary": {
                  "type": "boolean"
                }
              }
            }
          },
          "client_addresses": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "label": {
                  "type": "string"
                },
                "address": {
                  "type": "string"
                },
                "is_primary": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "CustomerCreate": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "phone": {
            "type": "string",
            "description": "US number, stored as E.164"
          },
          "phone_type": {
            "$ref": "#/components/schemas/PhoneType",
            "default": "cell"
          },
          "email": {
            "type": "string",
            "description": "Lower-cased"
          },
          "address": {
            "type": "string",
            "maxLength": 500,
            "description": "Saved as primary address"
          },
          "address_label": {
            "type": "string",
            "maxLength": 60,
            "default": "Service"
          },
          "notes": {
            "type": "string",
            "maxLength": 5000
          }
        }
      },
      "CustomerUpdate": {
        "type": "object",
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "notes": {
            "type": [
              "string",
              "null"
            ]
          },
          "is_active": {
            "type": "boolean"
          },
          "add_phone": {
            "type": "object",
            "required": [
              "phone"
            ],
            "properties": {
              "phone": {
                "type": "string"
              },
              "type": {
                "$ref": "#/components/schemas/PhoneType"
              },
              "is_primary": {
                "type": "boolean"
              }
            }
          },
          "add_address": {
            "type": "object",
            "required": [
              "address"
            ],
            "properties": {
              "address": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "is_primary": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "JobStatus": {
        "type": "string",
        "enum": [
          "new",
          "scheduled",
          "in_progress",
          "completed",
          "cancelled"
        ]
      },
      "Job": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "job_number": {
            "type": "string"
          },
          "client_id": {
            "type": "string",
            "format": "uuid"
          },
          "technician_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid",
            "description": "Lead technician"
          },
          "appliance_type": {
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "status": {
            "$ref": "#/components/schemas/JobStatus"
          },
          "scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "end_scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "is_anytime": {
            "type": "boolean"
          },
          "arrival_window_hours": {
            "type": "integer"
          },
          "visit_address": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "clients": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              },
              "phone": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "email": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "profiles": {
            "type": [
              "object",
              "null"
            ],
            "description": "Lead technician",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "technicians": {
            "type": "array",
            "description": "Whole crew, lead first",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "name": {
                  "type": "string"
                },
                "is_lead": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "JobCreate": {
        "type": "object",
        "required": [
          "customer_id"
        ],
        "properties": {
          "customer_id": {
            "type": "string",
            "format": "uuid"
          },
          "appliance_type": {
            "type": "string",
            "maxLength": 40,
            "description": "Normalised (e.g. fridge → Refrigerator)"
          },
          "description": {
            "type": "string",
            "maxLength": 5000
          },
          "visit_address": {
            "type": "string",
            "maxLength": 500,
            "description": "Matched to a saved address, or added. Default: primary address"
          },
          "zip": {
            "type": "string",
            "description": "Needed for scheduling if the address has no ZIP"
          },
          "scheduled_at": {
            "type": "string",
            "format": "date-time",
            "description": "Window start"
          },
          "technician_id": {
            "type": "string",
            "format": "uuid",
            "description": "Preferred technician"
          },
          "notify_customer": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "JobMutationResult": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Job"
          },
          "calendar": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string"
              }
            }
          },
          "sms": {
            "type": "object",
            "properties": {
              "ok": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "RescheduleRequest": {
        "type": "object",
        "required": [
          "scheduled_at"
        ],
        "properties": {
          "scheduled_at": {
            "type": "string",
            "format": "date-time"
          },
          "technician_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "notify": {
            "type": "boolean",
            "default": true
          },
          "caller_phone": {
            "type": "string",
            "description": "Must match a phone on the job's customer"
          }
        }
      },
      "RescheduleResult": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/Job"
          },
          "previous_scheduled_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "arrival_window_label": {
            "type": "string"
          },
          "timezone": {
            "type": "string"
          },
          "technician_reassigned": {
            "type": "boolean"
          },
          "notified": {
            "type": "boolean"
          },
          "calendar": {
            "type": "object",
            "properties": {
              "status": {
                "type": "string"
              }
            }
          },
          "sms": {
            "type": "object",
            "properties": {
              "ok": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "CancelRequest": {
        "type": "object",
        "properties": {
          "reason": {
            "type": "string",
            "maxLength": 1000
          },
          "notify": {
            "type": "boolean",
            "default": true
          },
          "caller_phone": {
            "type": "string"
          }
        }
      },
      "Availability": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date"
          },
          "zip": {
            "type": "string"
          },
          "serviced": {
            "type": "boolean"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "timezone": {
            "type": "string"
          },
          "now": {
            "type": "string",
            "format": "date-time"
          },
          "today_local": {
            "type": "string",
            "format": "date"
          },
          "current_local_time": {
            "type": "string"
          },
          "rules": {
            "type": "object",
            "properties": {
              "business_hours_local": {
                "type": "string"
              },
              "arrival_window_hours": {
                "type": "integer"
              },
              "last_window_start_hour_local": {
                "type": "integer"
              },
              "min_lead_time_minutes": {
                "type": "integer"
              },
              "max_jobs_per_tech_per_window": {
                "type": "integer"
              }
            }
          },
          "total_technicians_covering_zip": {
            "type": "integer"
          },
          "technicians_scheduled_on_date": {
            "type": "integer"
          },
          "windows": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "start": {
                  "type": "string",
                  "format": "date-time"
                },
                "end": {
                  "type": "string",
                  "format": "date-time"
                },
                "start_local_time": {
                  "type": "string"
                },
                "end_local_time": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "available_technicians": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "format": "uuid"
                      },
                      "name": {
                        "type": "string"
                      },
                      "service_region": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      },
      "LineItem": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string"
          },
          "quantity": {
            "type": "number"
          },
          "unit_price": {
            "type": "number"
          }
        }
      },
      "Estimate": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "doc_number": {
            "type": "string"
          },
          "job_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string"
          },
          "line_items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LineItem"
            }
          },
          "subtotal": {
            "type": "number"
          },
          "tax_rate": {
            "type": "number"
          },
          "tax_amount": {
            "type": "number"
          },
          "tax_jurisdiction": {
            "type": [
              "string",
              "null"
            ]
          },
          "total": {
            "type": "number"
          },
          "sent_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "responded_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "customer_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Invoice": {
        "allOf": [
          {
            "$ref": "#/components/schemas/Estimate"
          },
          {
            "type": "object",
            "properties": {
              "estimate_id": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid"
              },
              "invoice_type": {
                "type": "string"
              },
              "amount_paid": {
                "type": "number"
              },
              "paid_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              }
            }
          }
        ]
      }
    }
  }
}