{
  "openapi": "3.1.0",
  "info": {
    "title": "OTTO PROS API",
    "version": "2.10.1",
    "description": "Run a sub-account: leads, deal value and won/lost, pipeline stages, bookings and calendars, texts and emails, the inbox, calls, forms, automations and settings.\n\nAuthenticate with `Authorization: Bearer zu-...` (Settings → API). Every response is `{ success, data, error }`.\nA key works inside its own sub-account only, so `workspace_id` can be left out everywhere.\nMCP server: https://api.ottopros.com/mcp\n\n### Authentication\nSend your key as `Authorization: Bearer zu-...`. Admins of a sub-account create keys in the CRM under Settings → API. A key works inside its own sub-account only: you can leave out `workspace_id` everywhere, a different one is ignored, and records of any other sub-account answer 404. Access levels: Read only, Read and write, or Full access (deleting things, team members and anything that sends lead data outside the account). Every call also follows the role of the person who made the key: a key keeps working only while they are an admin of the sub-account.\n\n### Idempotency\nEvery write (POST, PUT, PATCH, DELETE) accepts `Idempotency-Key: <your-unique-string>`. Replaying the same key with the same body within 24 hours returns the original response instead of doing the work twice (no second message, no second booking); the same key with a different body answers 409. Use a fresh key per logical operation, not per retry.\n\n### Rate limits\nEvery response carries `X-RateLimit-Limit` and `X-RateLimit-Remaining`. On 429 a `Retry-After` header (and `retry_after_seconds` in the body) tells you how long to wait. The limit is per key, per minute: 120 by default, adjustable from 1 to 600 in Settings → API.\n\n### Pagination\nList endpoints accept `limit` (default 50, max 200) and return the newest rows first. GET /v1/messages is the one endpoint with a cursor: pass `cursor` (or `since`) and follow `next_cursor` to walk forward without duplicates.\n\n### Messaging safety limits\nTo protect number reputation, each sub-account can message at most 300 unique contacts per UTC day (plus per-minute burst and daily segment caps). Replying to a contact you already messaged that day does not consume another contact slot. Messaging endpoints return X-Contacts-Limit, X-Contacts-Used, X-Contacts-Remaining and X-Contacts-Reset; over the cap sends answer 429 with `code: \"sms_limit\"` and a `limit` object. Check the current state any time with GET /v1/messages/limits. Need a higher ceiling? Request a limit increase from Settings → Messaging and we'll review it.\n\n### Responses and errors\nSuccess is `{ success: true, data, error: null }`. Errors are `{ success: false, data: null, error: string, details?: object }` with a matching HTTP status; scope, rate-limit and budget errors put a machine-readable code in `error` (`scope_denied`, `rate_limit_exceeded`, `credit_limit_exceeded`) and the explanation in `message`. Branch on the status and the code, not on message text.\n"
  },
  "servers": [
    {
      "url": "https://api.ottopros.com",
      "description": "Production"
    }
  ],
  "x-webhooks": {
    "workspaceEvents": [
      {
        "event": "lead.created",
        "description": "A lead was captured for this sub-account. Payload is a full lead snapshot including custom form fields."
      },
      {
        "event": "lead.updated",
        "description": "The lead's status or pipeline stage changed (other field edits do not fire it). Payload carries previous_status, status, previous_stage_key and stage_key."
      },
      {
        "event": "lead.qualified",
        "description": "The lead was marked qualified."
      },
      {
        "event": "appointment.booked",
        "description": "An appointment was booked for the lead."
      },
      {
        "event": "appointment.rescheduled",
        "description": "An appointment moved to a new time, in the CRM calendar, through the API or by an inbound webhook. Payload carries booking_id, lead_id, the new starts_at / ends_at, timezone, host, calendar, meeting and moved_via (app, api or inbound_webhook)."
      },
      {
        "event": "appointment.cancelled",
        "description": "A booked appointment was cancelled."
      },
      {
        "event": "message.received",
        "description": "An inbound SMS or email arrived on this sub-account's number or inbox. Payload carries message_id, lead_id, channel, direction, body, from/to and media_urls, and `transport` (imessage or mac_sms) when it came in on one of the sub-account's iMessage Macs."
      },
      {
        "event": "message.sent",
        "description": "An outbound SMS or email was handed to the carrier or mail provider — manual, automated or API-sent. Texts carry `transport`: sms from the business number, imessage or mac_sms when one of the sub-account's Macs sent it."
      },
      {
        "event": "message.failed",
        "description": "An outbound message could not be sent. Payload includes the error and, when the contact-safety cap was hit, a `limit` object."
      },
      {
        "event": "call.completed",
        "description": "An AI receptionist call ended (once per call, after its recap is written; practice calls from Settings excluded). Payload carries call_id, lead_id (null for a caller with no lead), from/to, status, duration_sec, outcome, summary, booking_id and started_at / ended_at. The transcript and recording: GET /v1/calls/{call_id}."
      },
      {
        "event": "deal.updated",
        "description": "A lead was marked won, or a won lead's amount or plan changed later (an amount added from Ad Insights, a plan edited). Payload carries deal_type (one_time or plan), deal_value_cents (the first payment), deal_plan_cents, deal_plan_interval, deal_monthly_cents and deal_expected_total_cents, plus the lead snapshot. Every lead event's snapshot carries the same deal fields."
      }
    ],
    "signature": {
      "header": "X-Webhook-Signature",
      "format": "sha256=<hex hmac>",
      "description": "Each delivery is signed with HMAC-SHA256 over the exact raw request body using the webhook's secret (shown once when it is created). Compute the HMAC over the raw bytes, before JSON parsing, and compare in constant time. `X-Webhook-Event` carries the event name and `X-Webhook-Delivery` a unique delivery id you can use to de-duplicate retries."
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "CRM leads"
    },
    {
      "name": "Messaging"
    },
    {
      "name": "Bookings"
    },
    {
      "name": "Members"
    },
    {
      "name": "Smart forms"
    },
    {
      "name": "CRM automations"
    },
    {
      "name": "Workspaces"
    },
    {
      "name": "Setup"
    },
    {
      "name": "Offers"
    },
    {
      "name": "Calendars & hours"
    },
    {
      "name": "Team busy times"
    },
    {
      "name": "Pipeline & fields"
    },
    {
      "name": "Routing & alerts"
    },
    {
      "name": "Lead sources & webhooks"
    },
    {
      "name": "AI agent"
    },
    {
      "name": "Dashboard"
    },
    {
      "name": "Inbox"
    },
    {
      "name": "Calls"
    },
    {
      "name": "AI Brain"
    },
    {
      "name": "Invoices & reviews"
    },
    {
      "name": "Ads & Google"
    },
    {
      "name": "Support"
    },
    {
      "name": "Account"
    }
  ],
  "paths": {
    "/v1/leads": {
      "get": {
        "operationId": "list_leads",
        "tags": [
          "CRM leads"
        ],
        "summary": "List and filter leads",
        "description": "Newest first. Filter by tags (`tag_match=any` returns leads with at least one of the tags, `all` leads with every one), status, pipeline stage, assignee, a name / email / phone search and a created-since time. Each lead carries `inquiry` (the CRM's Inquiry column), `address`, `city`, `state`, `zip`, `custom_fields`, `tags` and `stage` (the pipeline stage it shows in). Page with `limit` and `offset`: `next_offset` is set while there are more.\n\nRequired scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "description": "Restrict to one sub-account (a key restricted to one sub-account always uses its own).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tags",
            "in": "query",
            "required": false,
            "description": "Tag names, comma-separated (tags=VIP,Roof), or a JSON array (tags=[\"Roof, metal\",\"VIP\"]) when a name has a comma. Max 10.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tag_match",
            "in": "query",
            "required": false,
            "description": "any (default): at least one of the tags. all: every tag.",
            "schema": {
              "type": "string",
              "enum": [
                "any",
                "all"
              ]
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "One or more statuses, comma-separated: new, contacted, qualified, booked, won, lost, spam, partial.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage_key",
            "in": "query",
            "required": false,
            "description": "Pipeline stage key from GET /v1/stages.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assigned_to",
            "in": "query",
            "required": false,
            "description": "A user id (GET /v1/members): leads assigned to them. \"me\": the key's own user. \"unassigned\": nobody's.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Matches name, email or phone (any format).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO timestamp: only leads created at or after it.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Default 50, max 200.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Skip this many leads; pass next_offset from the previous page.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "leads": [
                      {
                        "id": "lead-uuid",
                        "workspace_id": "ws-uuid",
                        "full_name": "Jane Doe",
                        "email": "jane@example.com",
                        "phone": "+14155550123",
                        "source": "api",
                        "status": "contacted",
                        "stage_key": "quote_sent",
                        "score": null,
                        "assigned_to": null,
                        "ad_name": null,
                        "campaign_name": null,
                        "deal_value_cents": null,
                        "deal_currency": "USD",
                        "created_at": "2026-09-23T15:00:00Z",
                        "updated_at": "2026-09-23T15:05:00Z",
                        "last_activity_at": "2026-09-23T15:05:00Z",
                        "stage": "quote_sent",
                        "inquiry": "Roof replacement quote",
                        "address": "12 Main St",
                        "city": "Pittsburgh",
                        "state": "PA",
                        "zip": "15213",
                        "custom_fields": {
                          "roof_type": "Metal",
                          "roof_age_years": 18
                        },
                        "tags": [
                          "Spring promo",
                          "VIP"
                        ]
                      }
                    ],
                    "has_more": false,
                    "next_offset": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_lead",
        "tags": [
          "CRM leads"
        ],
        "summary": "Create a lead",
        "description": "Needs workspace_id plus at least one of full_name, email or phone. Besides the lead's columns you can set `inquiry`, `address`, `city`, `state`, `zip`, `custom_fields` and `tags`. The lead and its tags are saved together, so automations that filter on tags see them; each tag fires the lead.tag_added automation trigger. A lead with the same phone (last 10 digits) or email already in the sub-account answers 409 with its `lead_id` and `matched_on` in `details`: update that lead instead. A field the API does not know answers 400 (it is never silently dropped). By default the intake doesn't run (no first text or AI opener, follow-ups, team alert or Instant Lead Connect); `run_intake: true` works it like any new lead from a form and `intake` in the response says what ran. Either way it is a new lead to the rest of the CRM, as one added by hand is: automations that start on a new lead or a tag run, AI calling campaigns that take new leads pick it up, and the lead.created webhook fires. Returns the lead as GET /v1/leads/{lead_id} shows it.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "full_name": {
                    "type": "string",
                    "description": "Lead name."
                  },
                  "email": {
                    "type": "string",
                    "description": "Email address."
                  },
                  "phone": {
                    "type": "string",
                    "description": "10-digit US number or + and a country code; stored as E.164."
                  },
                  "source": {
                    "type": "string",
                    "description": "Where the lead came from. Defaults to api.",
                    "enum": [
                      "meta_lead_ad",
                      "manual",
                      "website_form",
                      "import",
                      "api",
                      "other",
                      "sms_inbound",
                      "email_inbound",
                      "webhook",
                      "smart_form",
                      "smart_form_partial",
                      "site_widget",
                      "instagram",
                      "messenger",
                      "review_funnel",
                      "calendly",
                      "acuity"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "description": "Base lead status. To move a lead in the pipeline, send stage_key instead.",
                    "enum": [
                      "new",
                      "contacted",
                      "qualified",
                      "booked",
                      "won",
                      "lost",
                      "spam",
                      "partial"
                    ]
                  },
                  "stage_key": {
                    "type": "string",
                    "description": "Pipeline stage key from GET /v1/stages. A stage also sets the status it stands for."
                  },
                  "score": {
                    "type": "number",
                    "description": "A number 0-100 that is yours to set, e.g. a counter your automations keep. Nothing writes it for you (AI lead scoring is off)."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Internal notes."
                  },
                  "assigned_to": {
                    "type": "string",
                    "description": "User id of someone in the sub-account (GET /v1/members). The agency owner only with the owner's own key (the app never offers them to the sub-account's people; a lead already on them may stay). null unassigns. A change is logged on the lead's timeline (Lead assigned / Lead unassigned), as in the app."
                  },
                  "ad_name": {
                    "type": "string",
                    "description": "Ad the lead came from."
                  },
                  "campaign_name": {
                    "type": "string",
                    "description": "Campaign the lead came from."
                  },
                  "utm_source": {
                    "type": "string",
                    "description": "UTM source."
                  },
                  "utm_medium": {
                    "type": "string",
                    "description": "UTM medium."
                  },
                  "utm_campaign": {
                    "type": "string",
                    "description": "UTM campaign."
                  },
                  "utm_term": {
                    "type": "string",
                    "description": "UTM term."
                  },
                  "utm_content": {
                    "type": "string",
                    "description": "UTM content."
                  },
                  "landing_url": {
                    "type": "string",
                    "description": "Page the lead converted on."
                  },
                  "referrer_url": {
                    "type": "string",
                    "description": "Referring page."
                  },
                  "attribution_channel": {
                    "type": "string",
                    "description": "e.g. meta, google, organic, direct."
                  },
                  "gclid": {
                    "type": "string",
                    "description": "Google Ads click id. A lead with one is sent back to the sub-account's Google Ads by its click when it books or is won (CRM conversions)."
                  },
                  "gbraid": {
                    "type": "string",
                    "description": "Google Ads app-to-web click id."
                  },
                  "wbraid": {
                    "type": "string",
                    "description": "Google Ads web-to-app click id."
                  },
                  "fbclid": {
                    "type": "string",
                    "description": "Facebook click id."
                  },
                  "msclkid": {
                    "type": "string",
                    "description": "Microsoft Ads click id."
                  },
                  "deal_value_cents": {
                    "type": "number",
                    "description": "Deal value in cents: on a won job, what the customer paid (the Sales report's Sold, and the revenue sent to Meta)."
                  },
                  "deal_currency": {
                    "type": "string",
                    "description": "3-letter currency code. Default USD."
                  },
                  "deal_parts_cents": {
                    "type": "number",
                    "description": "Won job: what the parts cost, in cents (Sales report)."
                  },
                  "deal_tip_cents": {
                    "type": "number",
                    "description": "Won job: the tip the technician got, in cents."
                  },
                  "deal_sold_by": {
                    "type": "string",
                    "description": "Won job: the user id of the technician credited with the sale (GET /v1/members). null = whoever the lead is assigned to."
                  },
                  "deal_won_at": {
                    "type": "string",
                    "description": "When the job was won (ISO 8601). Set for you when status becomes won; send it to date a sale yourself."
                  },
                  "deal_type": {
                    "type": "string",
                    "description": "Plans & memberships: what the customer bought, one_time (a job) or plan (a plan or membership that pays again). null = one-time. A deal_plan_cents sent alone makes it a plan; one_time clears the plan.",
                    "enum": [
                      "one_time",
                      "plan"
                    ]
                  },
                  "deal_plan_cents": {
                    "type": "number",
                    "description": "Plan: its price in cents, charged every deal_plan_interval. deal_value_cents is the first payment (the plan price when you leave it out)."
                  },
                  "deal_plan_interval": {
                    "type": "string",
                    "description": "Plan: how often it's charged. Default month.",
                    "enum": [
                      "month",
                      "quarter",
                      "year"
                    ]
                  },
                  "deal_plan_start_date": {
                    "type": "string",
                    "description": "Plan: when it starts (YYYY-MM-DD). Default today."
                  },
                  "deal_plan_months": {
                    "type": "number",
                    "description": "Plan: how many months it runs (1-600). null = no end date: the business's default length counts (12 months unless changed in Settings > Features). Leads return deal_monthly_cents and deal_expected_total_cents (first payment + the plan price for the rest of its length)."
                  },
                  "inquiry": {
                    "type": "string",
                    "description": "What the lead asked about: the Inquiry column in the CRM (max 500). Without it the CRM shows the form or ad offer, then General inquiry."
                  },
                  "address": {
                    "type": "string",
                    "description": "Street address."
                  },
                  "city": {
                    "type": "string",
                    "description": "City."
                  },
                  "state": {
                    "type": "string",
                    "description": "State or region. A US state, Canadian province or Australian state is stored as its code (\"Texas\" -> \"TX\"), a Mexican state by name, like every other intake; the list follows the lead's country (its phone number, else the sub-account's country). Anything else is kept as sent."
                  },
                  "zip": {
                    "type": "string",
                    "description": "ZIP or postal code."
                  },
                  "custom_fields": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Custom field values keyed by field_key (GET /v1/custom-fields); a field's label also works. Values are checked against the field type: number/money/rating numbers, boolean true/false, date YYYY-MM-DD, datetime ISO 8601, select one of its options, multiselect a list of options. null or \"\" clears a value; fields you leave out keep their value."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tag names. New names are created in the sub-account (matched ignoring case). Max 50."
                  },
                  "run_intake": {
                    "type": "boolean",
                    "description": "Default false. true = work the lead like a new lead from a form: first text or AI opener, follow-ups, team alert, Instant Lead Connect."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "full_name": "Jane Doe",
                "phone": "+14155550123",
                "email": "jane@example.com",
                "inquiry": "Roof replacement quote",
                "address": "12 Main St",
                "city": "Pittsburgh",
                "state": "PA",
                "zip": "15213",
                "custom_fields": {
                  "roof_type": "Metal",
                  "roof_age_years": 18
                },
                "tags": [
                  "Spring promo",
                  "VIP"
                ],
                "run_intake": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead": {
                      "id": "lead-uuid",
                      "workspace_id": "ws-uuid",
                      "full_name": "Jane Doe",
                      "email": "jane@example.com",
                      "phone": "+14155550123",
                      "source": "api",
                      "status": "contacted",
                      "stage_key": "quote_sent",
                      "score": null,
                      "assigned_to": null,
                      "ad_name": null,
                      "campaign_name": null,
                      "deal_value_cents": null,
                      "deal_currency": "USD",
                      "created_at": "2026-09-23T15:00:00Z",
                      "updated_at": "2026-09-23T15:05:00Z",
                      "last_activity_at": "2026-09-23T15:05:00Z",
                      "stage": "quote_sent",
                      "inquiry": "Roof replacement quote",
                      "address": "12 Main St",
                      "city": "Pittsburgh",
                      "state": "PA",
                      "zip": "15213",
                      "custom_fields": {
                        "roof_type": "Metal",
                        "roof_age_years": 18
                      },
                      "tags": [
                        "Spring promo",
                        "VIP"
                      ]
                    },
                    "intake": {
                      "ran": true,
                      "greeted": true
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}": {
      "get": {
        "operationId": "get_lead",
        "tags": [
          "CRM leads"
        ],
        "summary": "Get one lead",
        "description": "The lead with every column, its raw_payload, the flattened `inquiry`, `address`, `city`, `state`, `zip`, `custom_fields`, `tags` and `stage`, plus its 50 most recent timeline events.\n\nRequired scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead": {
                      "id": "lead-uuid",
                      "workspace_id": "ws-uuid",
                      "full_name": "Jane Doe",
                      "email": "jane@example.com",
                      "phone": "+14155550123",
                      "source": "api",
                      "status": "contacted",
                      "stage_key": "quote_sent",
                      "score": null,
                      "assigned_to": null,
                      "ad_name": null,
                      "campaign_name": null,
                      "deal_value_cents": null,
                      "deal_currency": "USD",
                      "created_at": "2026-09-23T15:00:00Z",
                      "updated_at": "2026-09-23T15:05:00Z",
                      "last_activity_at": "2026-09-23T15:05:00Z",
                      "stage": "quote_sent",
                      "inquiry": "Roof replacement quote",
                      "address": "12 Main St",
                      "city": "Pittsburgh",
                      "state": "PA",
                      "zip": "15213",
                      "custom_fields": {
                        "roof_type": "Metal",
                        "roof_age_years": 18
                      },
                      "tags": [
                        "Spring promo",
                        "VIP"
                      ]
                    },
                    "events": [
                      {
                        "id": "event-uuid",
                        "event_type": "note",
                        "body": "Lead created via API",
                        "created_at": "2026-09-23T15:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update_lead",
        "tags": [
          "CRM leads"
        ],
        "summary": "Update a lead",
        "description": "Send only what changes; null or \"\" clears a value. `custom_fields` merges: values you leave out are kept. `tags` REPLACES all of the lead's tags; `add_tags` and `remove_tags` change only those (applied in that order: tags, add_tags, remove_tags). A body with only tag changes is fine. `stage_key` moves the lead in the pipeline and sets the status that stage stands for. A field the API does not know answers 400. Returns the updated lead.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "full_name": {
                    "type": "string",
                    "description": "Lead name."
                  },
                  "email": {
                    "type": "string",
                    "description": "Email address."
                  },
                  "phone": {
                    "type": "string",
                    "description": "10-digit US number or + and a country code; stored as E.164."
                  },
                  "source": {
                    "type": "string",
                    "description": "Where the lead came from. Defaults to api.",
                    "enum": [
                      "meta_lead_ad",
                      "manual",
                      "website_form",
                      "import",
                      "api",
                      "other",
                      "sms_inbound",
                      "email_inbound",
                      "webhook",
                      "smart_form",
                      "smart_form_partial",
                      "site_widget",
                      "instagram",
                      "messenger",
                      "review_funnel",
                      "calendly",
                      "acuity"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "description": "Base lead status. To move a lead in the pipeline, send stage_key instead.",
                    "enum": [
                      "new",
                      "contacted",
                      "qualified",
                      "booked",
                      "won",
                      "lost",
                      "spam",
                      "partial"
                    ]
                  },
                  "stage_key": {
                    "type": "string",
                    "description": "Pipeline stage key from GET /v1/stages. A stage also sets the status it stands for."
                  },
                  "score": {
                    "type": "number",
                    "description": "A number 0-100 that is yours to set, e.g. a counter your automations keep. Nothing writes it for you (AI lead scoring is off)."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Internal notes."
                  },
                  "assigned_to": {
                    "type": "string",
                    "description": "User id of someone in the sub-account (GET /v1/members). The agency owner only with the owner's own key (the app never offers them to the sub-account's people; a lead already on them may stay). null unassigns. A change is logged on the lead's timeline (Lead assigned / Lead unassigned), as in the app."
                  },
                  "ad_name": {
                    "type": "string",
                    "description": "Ad the lead came from."
                  },
                  "campaign_name": {
                    "type": "string",
                    "description": "Campaign the lead came from."
                  },
                  "utm_source": {
                    "type": "string",
                    "description": "UTM source."
                  },
                  "utm_medium": {
                    "type": "string",
                    "description": "UTM medium."
                  },
                  "utm_campaign": {
                    "type": "string",
                    "description": "UTM campaign."
                  },
                  "utm_term": {
                    "type": "string",
                    "description": "UTM term."
                  },
                  "utm_content": {
                    "type": "string",
                    "description": "UTM content."
                  },
                  "landing_url": {
                    "type": "string",
                    "description": "Page the lead converted on."
                  },
                  "referrer_url": {
                    "type": "string",
                    "description": "Referring page."
                  },
                  "attribution_channel": {
                    "type": "string",
                    "description": "e.g. meta, google, organic, direct."
                  },
                  "gclid": {
                    "type": "string",
                    "description": "Google Ads click id. A lead with one is sent back to the sub-account's Google Ads by its click when it books or is won (CRM conversions)."
                  },
                  "gbraid": {
                    "type": "string",
                    "description": "Google Ads app-to-web click id."
                  },
                  "wbraid": {
                    "type": "string",
                    "description": "Google Ads web-to-app click id."
                  },
                  "fbclid": {
                    "type": "string",
                    "description": "Facebook click id."
                  },
                  "msclkid": {
                    "type": "string",
                    "description": "Microsoft Ads click id."
                  },
                  "deal_value_cents": {
                    "type": "number",
                    "description": "Deal value in cents: on a won job, what the customer paid (the Sales report's Sold, and the revenue sent to Meta)."
                  },
                  "deal_currency": {
                    "type": "string",
                    "description": "3-letter currency code. Default USD."
                  },
                  "deal_parts_cents": {
                    "type": "number",
                    "description": "Won job: what the parts cost, in cents (Sales report)."
                  },
                  "deal_tip_cents": {
                    "type": "number",
                    "description": "Won job: the tip the technician got, in cents."
                  },
                  "deal_sold_by": {
                    "type": "string",
                    "description": "Won job: the user id of the technician credited with the sale (GET /v1/members). null = whoever the lead is assigned to."
                  },
                  "deal_won_at": {
                    "type": "string",
                    "description": "When the job was won (ISO 8601). Set for you when status becomes won; send it to date a sale yourself."
                  },
                  "deal_type": {
                    "type": "string",
                    "description": "Plans & memberships: what the customer bought, one_time (a job) or plan (a plan or membership that pays again). null = one-time. A deal_plan_cents sent alone makes it a plan; one_time clears the plan.",
                    "enum": [
                      "one_time",
                      "plan"
                    ]
                  },
                  "deal_plan_cents": {
                    "type": "number",
                    "description": "Plan: its price in cents, charged every deal_plan_interval. deal_value_cents is the first payment (the plan price when you leave it out)."
                  },
                  "deal_plan_interval": {
                    "type": "string",
                    "description": "Plan: how often it's charged. Default month.",
                    "enum": [
                      "month",
                      "quarter",
                      "year"
                    ]
                  },
                  "deal_plan_start_date": {
                    "type": "string",
                    "description": "Plan: when it starts (YYYY-MM-DD). Default today."
                  },
                  "deal_plan_months": {
                    "type": "number",
                    "description": "Plan: how many months it runs (1-600). null = no end date: the business's default length counts (12 months unless changed in Settings > Features). Leads return deal_monthly_cents and deal_expected_total_cents (first payment + the plan price for the rest of its length)."
                  },
                  "inquiry": {
                    "type": "string",
                    "description": "What the lead asked about: the Inquiry column in the CRM (max 500). Without it the CRM shows the form or ad offer, then General inquiry."
                  },
                  "address": {
                    "type": "string",
                    "description": "Street address."
                  },
                  "city": {
                    "type": "string",
                    "description": "City."
                  },
                  "state": {
                    "type": "string",
                    "description": "State or region. A US state, Canadian province or Australian state is stored as its code (\"Texas\" -> \"TX\"), a Mexican state by name, like every other intake; the list follows the lead's country (its phone number, else the sub-account's country). Anything else is kept as sent."
                  },
                  "zip": {
                    "type": "string",
                    "description": "ZIP or postal code."
                  },
                  "custom_fields": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Custom field values keyed by field_key (GET /v1/custom-fields); a field's label also works. Values are checked against the field type: number/money/rating numbers, boolean true/false, date YYYY-MM-DD, datetime ISO 8601, select one of its options, multiselect a list of options. null or \"\" clears a value; fields you leave out keep their value."
                  },
                  "tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "REPLACES all of the lead's tags ([] removes them all). To change only some, use add_tags / remove_tags."
                  },
                  "add_tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tag names to add; the lead's other tags stay. New names are created."
                  },
                  "remove_tags": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Tag names to remove."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "add_tags": [
                  "Hot lead"
                ],
                "remove_tags": [
                  "Cold"
                ],
                "stage_key": "quote_sent",
                "custom_fields": {
                  "roof_type": "Tile"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead": {
                      "id": "lead-uuid",
                      "workspace_id": "ws-uuid",
                      "full_name": "Jane Doe",
                      "email": "jane@example.com",
                      "phone": "+14155550123",
                      "source": "api",
                      "status": "contacted",
                      "stage_key": "quote_sent",
                      "score": null,
                      "assigned_to": null,
                      "ad_name": null,
                      "campaign_name": null,
                      "deal_value_cents": null,
                      "deal_currency": "USD",
                      "created_at": "2026-09-23T15:00:00Z",
                      "updated_at": "2026-09-23T15:05:00Z",
                      "last_activity_at": "2026-09-23T15:05:00Z",
                      "stage": "quote_sent",
                      "inquiry": "Roof replacement quote",
                      "address": "12 Main St",
                      "city": "Pittsburgh",
                      "state": "PA",
                      "zip": "15213",
                      "custom_fields": {
                        "roof_type": "Metal",
                        "roof_age_years": 18
                      },
                      "tags": [
                        "Spring promo",
                        "VIP"
                      ]
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_lead",
        "tags": [
          "CRM leads"
        ],
        "summary": "Delete a lead",
        "description": "With delete_appointments=true its appointments go first, each the way the calendar deletes one: the synced Google / Outlook event, the customer's invite (cancelled if it was still on), its reminder texts, then the appointment; if one can't be deleted the lead is kept and the answer says how many went. Without it the appointments stay on the calendar with no lead, as before.\n\nRequired scope: `leads:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "delete_appointments",
            "in": "query",
            "required": false,
            "description": "Also delete the lead's appointments (the app's \"Also delete their appointments\").",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "deleted": true,
                    "id": "uuid",
                    "appointments_deleted": 2
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/timeline": {
      "get": {
        "operationId": "lead_timeline",
        "tags": [
          "CRM leads"
        ],
        "summary": "Lead activity timeline",
        "description": "Required scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Default 50.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/notes": {
      "post": {
        "operationId": "create_lead_note",
        "tags": [
          "CRM leads"
        ],
        "summary": "Add a note to a lead",
        "description": "mentions tags teammates like @Name in the app's note box: each one on the sub-account's team who can see the lead gets an email and a push with the note and a link to the conversation (replies go to you); the answer lists who was told and who was skipped and why (not_on_team, cant_see_lead).\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "description": "Note text."
                  },
                  "actor_label": {
                    "type": "string",
                    "description": "Who the note is from."
                  },
                  "mentions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 20 user ids to tag (GET /v1/members)."
                  }
                },
                "required": [
                  "body"
                ],
                "additionalProperties": true
              },
              "example": {
                "body": "@Sam can you call her back after 5?",
                "mentions": [
                  "uuid"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "event": {
                      "id": "uuid",
                      "event_type": "note",
                      "body": "@Sam can you call her back after 5?"
                    },
                    "mentions": {
                      "tagged": [
                        {
                          "user_id": "uuid",
                          "name": "Sam Tech"
                        }
                      ],
                      "skipped": []
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/stage": {
      "post": {
        "operationId": "set_lead_stage",
        "tags": [
          "CRM leads"
        ],
        "summary": "Move a lead to a pipeline stage",
        "description": "PATCH on the same path does the same.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "stage_key": {
                    "type": "string",
                    "description": "Stage key from GET /v1/stages."
                  }
                },
                "required": [
                  "stage_key"
                ],
                "additionalProperties": true
              },
              "example": {
                "stage_key": "booked"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/stages": {
      "get": {
        "operationId": "list_stages",
        "tags": [
          "CRM leads"
        ],
        "summary": "List pipeline stages",
        "description": "Required scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_stage",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Add a pipeline stage",
        "description": "`behavior` is what the stage means for reporting. The key is made from the label and never changes.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "label": {
                    "type": "string",
                    "description": "Stage name (max 40)."
                  },
                  "behavior": {
                    "type": "string",
                    "description": "Default contacted.",
                    "enum": [
                      "new",
                      "contacted",
                      "booked",
                      "won",
                      "lost"
                    ]
                  },
                  "color": {
                    "type": "string",
                    "description": "Defaults to the first unused colour.",
                    "enum": [
                      "blue",
                      "amber",
                      "violet",
                      "cyan",
                      "emerald",
                      "rose",
                      "teal",
                      "orange",
                      "pink",
                      "indigo",
                      "lime",
                      "slate"
                    ]
                  },
                  "manual_only": {
                    "type": "boolean",
                    "description": "Moving a lead here does not change its status."
                  }
                },
                "required": [
                  "workspace_id",
                  "label"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "label": "Quote sent",
                "behavior": "contacted"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/tags": {
      "get": {
        "operationId": "list_tags",
        "tags": [
          "CRM leads"
        ],
        "summary": "List lead tags",
        "description": "Every tag in the sub-account and how many leads carry it. A tag is created automatically the first time you send its name in a lead's tags or add_tags.\n\nRequired scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "tags": [
                      {
                        "id": "tag-uuid",
                        "name": "VIP",
                        "color": "slate",
                        "lead_count": 12,
                        "created_at": "2026-09-01T10:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "send_message",
        "tags": [
          "Messaging"
        ],
        "summary": "Send an SMS or email",
        "description": "Sends from the sub-account's own number / verified sending domain and logs the message on the lead timeline. Email requires a subject. Address the message with `lead_id`, or with a raw `to` (E.164 phone for SMS, email address for email) plus `workspace_id` — OTTO PROS matches an existing contact or creates one. Every send counts against the daily unique-contact safety limit (300 contacts per UTC day by default); replies to contacts already messaged today are free of the cap. Over the cap the call answers 429. Each message is billed at the platform rate and counts against the key's monthly credit budget, if it has one (402 when the budget is used up); a text through one of the sub-account's iMessage Macs is free. The message is sent as the key's user, as from the Inbox: the conversation names them, the Activity Log records them, the numbers and Macs they may text from apply, and an archived conversation comes back to the Inbox.\n\nWith `send_at` the message is scheduled instead, exactly like the Inbox's \"Schedule message\": the call answers 201 with the scheduled message, and at that time it is sent from the lead's usual number or sender as the key's user, with the same opt-out, credit and limit checks as a send now (a refusal then marks it failed with the reason). A contact who opted out, or has no phone or email for the channel, is refused up front (400). A scheduled message counts against the key's credit budget when it is scheduled. See, change, cancel or send it early with /v1/scheduled-messages.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lead_id": {
                    "type": "string",
                    "description": "Lead to message. Omit when using `to`."
                  },
                  "to": {
                    "type": "string",
                    "description": "Raw destination: E.164 phone for sms, email address for email. Requires workspace_id."
                  },
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id. Required when using `to` (omit on pinned keys)."
                  },
                  "channel": {
                    "type": "string",
                    "description": "sms or email.",
                    "enum": [
                      "sms",
                      "email"
                    ]
                  },
                  "body": {
                    "type": "string",
                    "description": "Message text."
                  },
                  "subject": {
                    "type": "string",
                    "description": "Required for email."
                  },
                  "name": {
                    "type": "string",
                    "description": "Contact name used when `to` creates a new lead."
                  },
                  "media_urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 10 MMS/attachment URLs."
                  },
                  "actor_label": {
                    "type": "string",
                    "description": "Sender label shown in the timeline."
                  },
                  "send_at": {
                    "type": "string",
                    "description": "Schedule instead of sending now: ISO 8601 with a time zone (Z or an offset), e.g. 2026-10-20T09:00:00-05:00. In the future and at most 365 days ahead. Answers 201 with `scheduled_message`."
                  },
                  "send_as": {
                    "type": "string",
                    "description": "Texts, with an iMessage Mac connected (Beta): imessage sends a blue iMessage from one of the sub-account's iPhone numbers, sms from its business number, auto (default) lets the routing choose. The answer's `transport` says how it went (imessage, or mac_sms for the iPhone's own SMS).",
                    "enum": [
                      "auto",
                      "imessage",
                      "sms"
                    ]
                  },
                  "imessage_line_id": {
                    "type": "string",
                    "description": "Texts: which Mac (iPhone number) sends it (GET /v1/imessage/lines)."
                  },
                  "audio_message": {
                    "type": "boolean",
                    "description": "Texts: the one media_urls file is a voice message. Through a Mac running Advanced mode it arrives as a real iMessage audio message; anywhere else as an audio attachment. Not with send_at."
                  }
                },
                "required": [
                  "channel",
                  "body"
                ],
                "additionalProperties": true
              },
              "example": {
                "lead_id": "uuid",
                "channel": "sms",
                "body": "Hi Jane, are you still looking for a quote?"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "get": {
        "operationId": "list_messages",
        "tags": [
          "Messaging"
        ],
        "summary": "List recent messages on this sub-account",
        "description": "Every SMS and email on the sub-account's OTTO PROS numbers and inboxes, newest first. For polling, pass `cursor` (or `since`) — results then come oldest-first and `next_cursor` walks forward with no duplicates and no missed messages. Poll no more than once every 10 seconds, or subscribe to the `message.received` webhook instead. A text that went through one of the sub-account's iMessage Macs carries `transport` (imessage, or mac_sms for the iPhone's own green text) and `imessage` { line_id, from, service: imessage | sms | rcs, delivered_at, read_at }; a tapback carries `reaction` { by: them | you, type, emoji, reacts_to: the message it hangs on, removed }.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on pinned keys).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "Only messages with this contact.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "description": "sms or email.",
            "schema": {
              "type": "string",
              "enum": [
                "sms",
                "email"
              ]
            }
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "description": "inbound or outbound.",
            "schema": {
              "type": "string",
              "enum": [
                "inbound",
                "outbound"
              ]
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO-8601 timestamp; returns messages created after it, oldest-first.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "`next_cursor` from the previous poll.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Default 50, max 200.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/scheduled-messages": {
      "get": {
        "operationId": "list_scheduled_messages",
        "tags": [
          "Messaging"
        ],
        "summary": "List scheduled texts and emails",
        "description": "Messages waiting to be sent later, scheduled in the Inbox or with POST /v1/messages and `send_at`. By default the upcoming ones (pending, sending, failed), soonest first, like the dashed bubbles at the end of a conversation; `status` = sent, cancelled or all lists history, newest first. A failed message carries `last_error`. Viewers limited to their own leads only see those leads' messages.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "Only this lead's messages.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Default upcoming (pending, sending, failed).",
            "schema": {
              "type": "string",
              "enum": [
                "upcoming",
                "pending",
                "sending",
                "failed",
                "sent",
                "cancelled",
                "all"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "scheduled_messages": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "lead_id": "uuid",
                        "channel": "sms",
                        "body": "Hi Jane, just checking in about your quote.",
                        "subject": null,
                        "from_number": null,
                        "from_sender_id": null,
                        "media_urls": [],
                        "attachment_urls": [],
                        "attachment_names": [],
                        "scheduled_at": "2026-10-20T14:00:00+00:00",
                        "status": "pending",
                        "attempts": 0,
                        "last_error": null,
                        "sent_at": null,
                        "lead_event_id": null,
                        "created_by": "uuid",
                        "cancelled_at": null,
                        "cancelled_by": null,
                        "created_at": "2026-10-16T18:02:11Z",
                        "updated_at": "2026-10-16T18:02:11Z",
                        "lead": {
                          "id": "uuid",
                          "full_name": "Jane Doe",
                          "phone": "+14155550123",
                          "email": null
                        }
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/scheduled-messages/{scheduled_message_id}": {
      "patch": {
        "operationId": "update_scheduled_message",
        "tags": [
          "Messaging"
        ],
        "summary": "Change, cancel or restore a scheduled message",
        "description": "Like the Inbox's Edit, Cancel and Undo. Send any of body, subject (emails), scheduled_at and media_urls (texts) to change a pending or failed message: it goes back in the queue (status pending). `status: \"cancelled\"` (on its own) stops it; `status: \"pending\"` brings a cancelled one back (send a new scheduled_at when its time has passed). 409 when it is sending or already sent. Owners and admins only.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scheduled_message_id",
            "in": "path",
            "required": true,
            "description": "Scheduled message id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "description": "The new text."
                  },
                  "subject": {
                    "type": "string",
                    "description": "The new subject (emails only)."
                  },
                  "scheduled_at": {
                    "type": "string",
                    "description": "ISO 8601 with a time zone, in the future and at most 365 days ahead."
                  },
                  "media_urls": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Picture URLs for a text, max 10 (replaces the list)."
                  },
                  "status": {
                    "type": "string",
                    "description": "cancelled to cancel, pending to restore.",
                    "enum": [
                      "pending",
                      "cancelled"
                    ]
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "scheduled_at": "2026-10-21T09:00:00-05:00",
                "body": "Hi Jane, following up on your quote. Any questions?"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "scheduled_message": {
                      "id": "uuid",
                      "channel": "sms",
                      "body": "Hi Jane, following up on your quote. Any questions?",
                      "scheduled_at": "2026-10-21T14:00:00+00:00",
                      "status": "pending"
                    },
                    "changed": true
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/scheduled-messages/{scheduled_message_id}/send-now": {
      "post": {
        "operationId": "send_scheduled_message_now",
        "tags": [
          "Messaging"
        ],
        "summary": "Send a scheduled message now",
        "description": "The Inbox's \"Send now\": a pending or failed message goes out at once, as the teammate who scheduled it, with the usual opt-out, credit and limit checks, and is billed like any text or email. 200 = sent; 202 = a sending hiccup, it tries again by itself in a couple of minutes; 400 = refused, with the reason (the message is marked failed); 409 = cancelled, already sending or sent. Refused when the key's credit budget is used up. Owners and admins only.\n\nRequired scope: `messaging:write`.\n\nSpends credits.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scheduled_message_id",
            "in": "path",
            "required": true,
            "description": "Scheduled message id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "sent": true,
                    "scheduled_message": {
                      "id": "uuid",
                      "status": "sent",
                      "sent_at": "2026-10-16T18:05:02Z",
                      "lead_event_id": "uuid"
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/ConfirmationRequired"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/messages/{message_id}": {
      "get": {
        "operationId": "get_message",
        "tags": [
          "Messaging"
        ],
        "summary": "Read one message",
        "description": "Required scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "description": "Message id from GET /v1/messages.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/messages/limits": {
      "get": {
        "operationId": "message_limits",
        "tags": [
          "Messaging"
        ],
        "summary": "Check today's contact-safety limits",
        "description": "Returns the daily unique-contact cap (default 300 per UTC day), how many contacts have been used, what's left, segment usage and the reset time. The same values ride on every messaging call as X-Contacts-Limit / -Used / -Remaining / -Reset headers.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on pinned keys).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/conversation": {
      "get": {
        "operationId": "lead_conversation",
        "tags": [
          "Messaging"
        ],
        "summary": "Read the SMS/email thread with a lead",
        "description": "Required scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Default 50.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/imessage/lines": {
      "get": {
        "operationId": "list_imessage_lines",
        "tags": [
          "Messaging"
        ],
        "summary": "List the sub-account's iMessage Macs",
        "description": "Every Mac connected to the sub-account for iMessage, the default first: its iPhone number, whose Mac it is, whether it's online, what the Mac reports about itself (`health`: Messages signed in, Full Disk Access, awake, lid closed allowed, iCloud still syncing, the number missing from or switched off in Messages), whether Advanced mode runs on it (`advanced_mode`: real audio messages and reactions), its settings (scope, create_leads, new_conversations, fallback, offline_minutes, ai_replies), who can text from it (access, allowed_user_ids, and can_use for you), its limits (new conversations a day and an hour, tries and length before someone first replies) and today's usage (new conversations today and this hour, messages waiting, every text it sent today, and how many other accounts share that iPhone's limit). `has_number` says whether the sub-account has a business number to fall back on; without one every text goes through a Mac. Any member. Connecting and disconnecting a Mac happen in the app.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lines": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "number": "+17145550123",
                        "handles": [
                          "+17145550123"
                        ],
                        "label": null,
                        "device_name": "Front desk iMac",
                        "owner": {
                          "user_id": "uuid",
                          "name": "Pat Owner"
                        },
                        "is_default": true,
                        "online": true,
                        "last_seen_at": "2026-10-23T15:32:02Z",
                        "connected_at": "2026-10-01T16:00:00Z",
                        "app_version": "0.6.3",
                        "macos_version": "15.6",
                        "advanced_mode": false,
                        "health": {
                          "messages_running": true,
                          "signed_in": true,
                          "full_disk_access": true,
                          "automation": true,
                          "awake": true,
                          "login_item": true,
                          "laptop": false,
                          "lid_closed_ok": null,
                          "on_battery": false,
                          "icloud_syncing": false,
                          "has_number": true,
                          "number_off": false,
                          "advanced": false,
                          "advanced_ready": false
                        },
                        "settings": {
                          "scope": "crm",
                          "create_leads": true,
                          "new_conversations": "sms",
                          "fallback": "mac_then_number",
                          "offline_minutes": 10,
                          "ai_replies": true
                        },
                        "access": "everyone",
                        "allowed_user_ids": [],
                        "can_use": true,
                        "can_manage": true,
                        "limits": {
                          "new_per_day": 50,
                          "new_per_hour": 6,
                          "first_contact_messages": 5,
                          "first_contact_chars": 300
                        },
                        "usage": {
                          "new_today": 12,
                          "new_this_hour": 2,
                          "waiting": 0,
                          "shared_with": 0,
                          "messages_today": 41
                        }
                      }
                    ],
                    "has_number": true
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/imessage/lines/{line_id}": {
      "patch": {
        "operationId": "update_imessage_line",
        "tags": [
          "Messaging"
        ],
        "summary": "Change an iMessage Mac's settings",
        "description": "Send only what changes. The sub-account's owners and admins change any Mac; everyone else only their own; only owners and admins choose the default (is_default: true moves it from the old one). access: everyone, owner (only the person whose Mac it is) or selected (allowed_user_ids); owners, admins and the Mac's owner can always text from it, and AI replies and automations aren't limited.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "line_id",
            "in": "path",
            "required": true,
            "description": "The Mac (GET /v1/imessage/lines).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "description": "A name for it (max 80), or null."
                  },
                  "is_default": {
                    "type": "boolean",
                    "description": "true makes it the default Mac."
                  },
                  "access": {
                    "type": "string",
                    "description": "Who can text from it by hand.",
                    "enum": [
                      "everyone",
                      "owner",
                      "selected"
                    ]
                  },
                  "allowed_user_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "With access selected: the team members who can."
                  },
                  "scope": {
                    "type": "string",
                    "description": "crm: only conversations with people already in the CRM sync; all: every one-to-one conversation.",
                    "enum": [
                      "crm",
                      "all"
                    ]
                  },
                  "create_leads": {
                    "type": "boolean",
                    "description": "With scope all: someone new who texts in becomes a lead."
                  },
                  "new_conversations": {
                    "type": "string",
                    "description": "How a first text to someone goes.",
                    "enum": [
                      "sms",
                      "imessage"
                    ]
                  },
                  "fallback": {
                    "type": "string",
                    "description": "When they aren't on iMessage or the Mac is offline: the business number, RCS or SMS from the iPhone through the Mac, the iPhone and then the business number (mac_then_number, the default), or nothing.",
                    "enum": [
                      "number",
                      "mac",
                      "mac_then_number",
                      "none"
                    ]
                  },
                  "offline_minutes": {
                    "type": "number",
                    "description": "How long a message waits for an offline Mac before the fallback, 2-240."
                  },
                  "ai_replies": {
                    "type": "boolean",
                    "description": "The AI texter may answer iMessages."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "access": "selected",
                "allowed_user_ids": [
                  "uuid"
                ],
                "new_conversations": "imessage"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "line": {
                      "id": "uuid",
                      "number": "+17145550123",
                      "access": "selected",
                      "allowed_user_ids": [
                        "uuid"
                      ],
                      "settings": {
                        "new_conversations": "imessage"
                      }
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/messages/{message_id}/reaction": {
      "post": {
        "operationId": "react_to_message",
        "tags": [
          "Messaging"
        ],
        "summary": "React to an iMessage (tapback)",
        "description": "Puts a tapback (❤️ 👍 👎 😂 ‼️ ❓) on a text that went through one of the sub-account's Macs, like the Inbox's reaction picker; `remove: true` takes yours back. Only a Mac running Advanced mode can (`advanced_mode` on GET /v1/imessage/lines): otherwise 409 `advanced_off`. The reaction is queued (202) and shows on the message (its `reaction`, by you) once the Mac has sent it; if it can't, a note says why on the conversation. Anyone who can see the lead and text from that number. Free, like every text through a Mac.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "description": "The text to react to (an id from GET /v1/messages or the lead's conversation).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reaction": {
                    "type": "string",
                    "description": "love, like, dislike, laugh, emphasize or question (or the emoji).",
                    "enum": [
                      "love",
                      "like",
                      "dislike",
                      "laugh",
                      "emphasize",
                      "question"
                    ]
                  },
                  "remove": {
                    "type": "boolean",
                    "description": "true takes your reaction back."
                  }
                },
                "required": [
                  "reaction"
                ],
                "additionalProperties": true
              },
              "example": {
                "reaction": "love"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "queued": true,
                    "job_id": "uuid",
                    "message_id": "uuid",
                    "reaction": "love",
                    "remove": false,
                    "line_id": "uuid"
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendars": {
      "get": {
        "operationId": "list_calendars",
        "tags": [
          "Bookings"
        ],
        "summary": "List booking calendars",
        "description": "Every setting POST / PATCH /v1/calendars takes, read the way the booking page reads it: hours, length, buffers, hosts' mode, texts, pricing (with each option's and add-on's id, used by availability and bookings), design, duration_days (full-day jobs), schedule_group (shared schedule), fields and questions (the booking form), image_url, the payment settings, a summary (price_from_cents, price_to_cents, length_label such as \"4-6 hr\", has_options, takes_payment) and booking_path (/c/<slug>).\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "calendars": [
                      {
                        "id": "uuid",
                        "slug": "triple-t-interior-exterior",
                        "name": "Triple T Interior + Exterior",
                        "title": "Triple T Interior + Exterior",
                        "duration_minutes": 240,
                        "duration_days": null,
                        "schedule_group": "Main crew",
                        "assignment_mode": "unassigned",
                        "slots_per_window": 1,
                        "max_days_ahead": 120,
                        "pricing": {
                          "enabled": true,
                          "show_prices": true,
                          "price_cents": null,
                          "price_note": null,
                          "options_label": "Vehicle size",
                          "options": [
                            {
                              "id": "opt-car",
                              "name": "Car",
                              "description": null,
                              "price_cents": 31500,
                              "duration_minutes": 240,
                              "duration_days": null,
                              "image_url": null
                            },
                            {
                              "id": "opt-van",
                              "name": "Van",
                              "description": null,
                              "price_cents": 53500,
                              "duration_minutes": 360,
                              "duration_days": null,
                              "image_url": null
                            }
                          ],
                          "addons_label": "Add-ons",
                          "addons": [
                            {
                              "id": "add-pet",
                              "name": "Pet hair",
                              "description": null,
                              "price_cents": 4000,
                              "extra_minutes": 30,
                              "image_url": null
                            }
                          ],
                          "deposit": {
                            "mode": "fixed",
                            "amount_cents": 5000,
                            "percent": 25
                          }
                        },
                        "design": null,
                        "questions": [
                          {
                            "key": "vehicle",
                            "label": "Vehicle year / make / model",
                            "field_type": "text",
                            "options": [],
                            "required": true,
                            "enabled": true,
                            "save_to_crm": true,
                            "placeholder": null,
                            "helper_text": null
                          }
                        ],
                        "summary": {
                          "price_from_cents": 31500,
                          "price_to_cents": 53500,
                          "length_label": "4-6 hr",
                          "has_options": true,
                          "takes_payment": true
                        },
                        "booking_path": "/c/triple-t-interior-exterior",
                        "is_active": true
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_calendar",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Create a booking calendar",
        "description": "A new calendar has no host unless host_user_id or hosts is sent. Hosts must be members of the sub-account (GET /v1/members). The response is the calendar as GET /v1/calendars shows it, with its public booking path (/c/<slug>). Calendars are switched off with is_active=false rather than deleted. The booking page can show prices with options and add-ons and take a deposit (pricing), have its own look (design), book whole working days (duration_days), share one schedule with other calendars (schedule_group) and ask its own questions (questions). Taking money at booking needs Stripe, Authorize.net or Whop connected to the sub-account in the app first.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Calendar name (max 80)."
                  },
                  "title": {
                    "type": "string",
                    "description": "Shown to the person booking."
                  },
                  "duration_minutes": {
                    "type": "number",
                    "description": "5-1440, default 30."
                  },
                  "buffer_minutes": {
                    "type": "number",
                    "description": "0-1440, default 0. Always saved as 0 on an arrival_window calendar (a window books the whole window and pads nothing), as in the app."
                  },
                  "min_notice_minutes": {
                    "type": "number",
                    "description": "Default 60."
                  },
                  "max_days_ahead": {
                    "type": "number",
                    "description": "1-365, default 14."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA zone, e.g. America/Chicago. Defaults to the sub-account's."
                  },
                  "weekly_hours": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Per day, 24h HH:MM windows: {\"mon\":[[\"09:00\",\"17:00\"]],\"sat\":[]}. Default Mon-Fri 9-5."
                  },
                  "date_overrides": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Days off or special hours: [{\"date\":\"2026-12-25\",\"pairs\":[]}]."
                  },
                  "assignment_mode": {
                    "type": "string",
                    "description": "Who takes the booking. Default unassigned (no host), or single when host_user_id is sent.",
                    "enum": [
                      "single",
                      "round_robin",
                      "collective",
                      "unassigned"
                    ]
                  },
                  "host_user_id": {
                    "type": "string",
                    "description": "Host of a single-host calendar (required for single)."
                  },
                  "hosts": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "User ids sharing a round_robin / collective calendar."
                  },
                  "meeting_type": {
                    "type": "string",
                    "description": "Default phone. in_person: the customer comes to meeting_location (studio, shop, office). customer_address: the team goes to the customer's home, and the booking page asks for their address.",
                    "enum": [
                      "zoom",
                      "google_meet",
                      "phone",
                      "phone_attendee",
                      "in_person",
                      "customer_address",
                      "custom"
                    ]
                  },
                  "scheduling_mode": {
                    "type": "string",
                    "description": "exact times, or an arrival window for trades.",
                    "enum": [
                      "exact",
                      "arrival_window"
                    ]
                  },
                  "arrival_window_minutes": {
                    "type": "number",
                    "description": "15-720."
                  },
                  "appointment_texts": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Confirmation and reminder texts for appointments on this calendar, keyed by confirmation, reminder_24h, reminder_1h, reminder_5m. Each takes {\"mode\":\"custom\",\"template\":\"...\"} (this wording, sent even when the sub-account has that text off), {\"mode\":\"off\"} (never sent for this calendar), or null / {\"mode\":\"inherit\"} (the sub-account's text, the default). Only the texts you name change."
                  },
                  "slots_per_window": {
                    "type": "number",
                    "description": "1-50: how many jobs can run at the same moment (crews)."
                  },
                  "duration_days": {
                    "type": "number",
                    "description": "Full-day jobs, 1-14 working days: each booking runs from opening time on its first day to closing time on its last, skipping closed days. null = timed by duration_minutes."
                  },
                  "schedule_group": {
                    "type": "string",
                    "description": "Shared schedule name (max 60): calendars with the same group count each other's bookings, so one crew's time is never sold twice across services. null = its own schedule."
                  },
                  "pricing": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Prices on the booking page. Merged into what the calendar has, except options and addons, which replace their lists (send each row's id to keep it; ids come back in GET /v1/calendars). Money in cents. { enabled, show_prices, price_cents (no options), price_note (max 160), options_label (\"Vehicle size\"), options: [{ id?, name (max 80), description?, price_cents, duration_minutes (5-1440, its own job length), duration_days (full-day calendars), image_url? }] (max 24; the customer picks one), addons_label, addons: [{ id?, name, description?, price_cents, extra_minutes (0-720), image_url? }] (max 24), deposit: { mode: none | fixed | percent | full, amount_cents, percent (1-100) } }. A calendar that never had pricing switches it on unless enabled is false; null clears it. A deposit needs a connected gateway."
                  },
                  "design": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "The booking page look, merged into the current design. { enabled, preset (clean, showroom, midnight, fresh, warm, bold, ocean, spa, mono, graphite: applied first), mode: light | dark | auto, colors: { background, surface, text, button } (#rrggbb, merged), font, heading_font (\"match\" or a font), radius: sharp | soft | rounded | pill, button_style: solid | soft | outline, backdrop: solid | glow | photo, logo_url, cover_url (https), hide_avatar, custom_css (max 12000) }. Fonts: inter, poppins, dm-sans, space-grotesk, manrope, outfit, figtree, plus-jakarta, work-sans, rubik, nunito-sans, montserrat, raleway, urbanist, sora, lexend, archivo, barlow, karla, public-sans, bricolage, bebas, anton, archivo-black, syne, clash, oswald, playfair, dm-serif, lora, libre-baskerville, cormorant, instrument-serif, fraunces, source-serif, merriweather, jetbrains-mono, space-mono, ibm-plex-mono, system. A page that never had a design switches it on unless enabled is false; null = the classic page. It carries into embeds and custom domains."
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The calendar's own booking questions, up to 30, replacing the list: [{ key?, label (max 160), field_type: text | textarea | number | money | phone | email | url | select | multiselect | boolean | date | datetime | rating | file (photos or PDFs, up to 6), options (select / multiselect: 2-40), option_style?, required?, enabled?, save_to_crm? (never for file), placeholder?, helper_text? }]. Answers show on the appointment and the lead."
                  },
                  "fields": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Contact fields on the booking form, merged: {\"address\":{\"enabled\":true,\"required\":true,\"autocomplete\":true},\"email\":{\"required\":false}}. Keys: full_name, first_name, last_name, email, phone, address, state, notes. Phone or email stays on; full_name or first_name + last_name."
                  },
                  "image_url": {
                    "type": "string",
                    "description": "The service's photo (https): on its booking page and its service menu card."
                  },
                  "currency": {
                    "type": "string",
                    "description": "Prices and payments in this currency.",
                    "enum": [
                      "usd",
                      "cad",
                      "gbp",
                      "eur",
                      "aud"
                    ]
                  },
                  "payment_gateway": {
                    "type": "string",
                    "description": "Charge through this connected gateway; null = whichever is connected (Stripe first).",
                    "enum": [
                      "stripe",
                      "authorize_net",
                      "whop"
                    ]
                  },
                  "payment_hold_minutes": {
                    "type": "number",
                    "description": "15-120: how long the time is held while they pay."
                  },
                  "payment_label": {
                    "type": "string",
                    "description": "What the checkout calls the payment, e.g. \"Deposit\" (max 60)."
                  }
                },
                "required": [
                  "workspace_id",
                  "name"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "name": "Triple T Interior + Exterior",
                "duration_minutes": 240,
                "assignment_mode": "unassigned",
                "schedule_group": "Main crew",
                "max_days_ahead": 120,
                "pricing": {
                  "options_label": "Vehicle size",
                  "options": [
                    {
                      "name": "Car",
                      "price_cents": 31500,
                      "duration_minutes": 240
                    },
                    {
                      "name": "SUV",
                      "price_cents": 38500,
                      "duration_minutes": 300
                    },
                    {
                      "name": "Van",
                      "price_cents": 53500,
                      "duration_minutes": 360
                    }
                  ],
                  "addons": [
                    {
                      "name": "Pet hair",
                      "price_cents": 4000,
                      "extra_minutes": 30
                    }
                  ],
                  "deposit": {
                    "mode": "fixed",
                    "amount_cents": 5000
                  }
                },
                "design": {
                  "preset": "showroom"
                },
                "questions": [
                  {
                    "label": "Vehicle year / make / model",
                    "field_type": "text",
                    "required": true
                  },
                  {
                    "label": "Photos of the vehicle",
                    "field_type": "file"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendars/{calendar_id}/availability": {
      "get": {
        "operationId": "calendar_availability",
        "tags": [
          "Bookings"
        ],
        "summary": "Get open appointment slots",
        "description": "The times the calendar's booking page offers, worked out the same way: weekly hours and days off, the job length, buffers, capacity (slots_per_window jobs at one moment), calendars sharing its schedule, max per day, minimum notice, the booking window (max_days_ahead, up to a year) and the hosts' own calendars. A calendar with options times each one differently, so send option_id (400 lists the options otherwise) and any addon_ids; the answer carries a quote (option, add-ons, length, total, deposit, balance). Full-day calendars also return slot_ends (when each start's job is done). Always call this before creating a booking.\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "calendar_id",
            "in": "path",
            "required": true,
            "description": "Calendar id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "A date (2026-11-03) or an ISO time; defaults to today.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "1-42, default 7.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "option_id",
            "in": "query",
            "required": false,
            "description": "The option picked (its id in GET /v1/calendars pricing.options). Required on a calendar with options.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "addon_ids",
            "in": "query",
            "required": false,
            "description": "Add-on ids, comma-separated: they add their time to the job.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "calendar": {
                      "id": "uuid",
                      "name": "Triple T Interior + Exterior",
                      "timezone": "America/Chicago",
                      "duration_minutes": 390,
                      "duration_days": null,
                      "booking_window_days": 120
                    },
                    "from": "2026-11-03T06:00:00.000Z",
                    "to": "2026-11-10T06:00:00.000Z",
                    "from_date": "2026-11-03",
                    "to_date": "2026-11-10",
                    "slots": [
                      "2026-11-03T14:00:00.000Z"
                    ],
                    "days": [
                      {
                        "date": "2026-11-03",
                        "label": "Tue, Nov 3",
                        "slots": [
                          "2026-11-03T14:00:00.000Z"
                        ]
                      }
                    ],
                    "quote": {
                      "option": {
                        "id": "opt-van",
                        "name": "Van"
                      },
                      "addons": [
                        {
                          "id": "add-pet",
                          "name": "Pet hair"
                        }
                      ],
                      "duration_minutes": 390,
                      "duration_days": null,
                      "length_label": "6 hr 30 min",
                      "total_cents": 57500,
                      "deposit_cents": 5000,
                      "balance_cents": 52500,
                      "currency": "usd",
                      "lines": [
                        {
                          "label": "Van",
                          "cents": 53500,
                          "kind": "option"
                        },
                        {
                          "label": "Pet hair",
                          "cents": 4000,
                          "kind": "addon"
                        }
                      ]
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/bookings": {
      "get": {
        "operationId": "list_bookings",
        "tags": [
          "Bookings"
        ],
        "summary": "List appointments",
        "description": "Soonest first. Each appointment has the same fields as everywhere else in the API: id, lead_id, calendar_id, appointment_number (the sub-account's #1001 and up, as the calendar shows it), title, starts_at, ends_at, timezone, lead_timezone, location, notes, meeting_type, meeting_location, meeting_url, host_user_id, status, source, notify_lead, is_arrival_window (booked as an arrival window: starts_at to ends_at is the window), service_details (on a priced calendar: the service, option, add-ons, length, total_cents, deposit_cents, balance_cents and currency; null otherwise), created_at and updated_at.\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "ISO start.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "ISO end.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "Filter by lead.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "bookings": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "lead_id": "uuid",
                        "calendar_id": "uuid",
                        "title": "Estimate",
                        "starts_at": "2026-09-04T17:00:00Z",
                        "ends_at": "2026-09-04T19:00:00Z",
                        "timezone": "America/Chicago",
                        "lead_timezone": "America/Chicago",
                        "location": "12 Main St",
                        "notes": null,
                        "meeting_type": "in_person",
                        "meeting_location": null,
                        "meeting_url": null,
                        "host_user_id": "uuid",
                        "status": "scheduled",
                        "source": "api",
                        "notify_lead": true,
                        "is_arrival_window": true,
                        "service_details": null,
                        "created_at": "2026-09-01T15:00:00Z",
                        "updated_at": "2026-09-01T15:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_booking",
        "tags": [
          "Bookings"
        ],
        "summary": "Book an appointment",
        "description": "Books like the app: rejects a second overlapping appointment for the same lead; calendar_id must be one of the sub-account's calendars (404 otherwise); ends_at must be after starts_at and at most 24 hours later. With a calendar, the slot's capacity is checked, calendars sharing its schedule included (409 with code slot_full; pick a time from GET /v1/calendars/{calendar_id}/availability, or send force: true) and the host is picked by the calendar's round robin. On a priced calendar, option_id and addon_ids set the job's length and price: the booking's notes start with the pick and its service_details carry the option, add-ons, total, deposit and balance; the lead's deal value is filled when it has none (the response adds a quote; a warning says when a calendar with options was booked without one). Bookings made through the API never take the deposit: to collect it, send the customer the booking link. A full-day calendar's job starts at opening time and ends at closing time on its last working day (400 not_a_start_time otherwise, unless ends_at is sent). By default the lead gets the confirmation and reminder texts and the calendar invite (notify_lead: false to skip them). Fires the appointment.booked outbound webhooks.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id."
                  },
                  "starts_at": {
                    "type": "string",
                    "description": "ISO 8601 start time."
                  },
                  "ends_at": {
                    "type": "string",
                    "description": "ISO 8601 end time (instead of duration_minutes; at most 24 h after starts_at, 31 days on a full-day calendar)."
                  },
                  "lead_id": {
                    "type": "string",
                    "description": "Lead to book."
                  },
                  "calendar_id": {
                    "type": "string",
                    "description": "One of the sub-account's calendars."
                  },
                  "option_id": {
                    "type": "string",
                    "description": "The option booked (GET /v1/calendars pricing.options id), e.g. the vehicle size."
                  },
                  "addon_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Add-ons booked (pricing.addons ids)."
                  },
                  "duration_minutes": {
                    "type": "number",
                    "description": "5-1440. Default: the option's length with its add-ons, else the calendar's, else 30."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA timezone."
                  },
                  "location": {
                    "type": "string",
                    "description": "Meeting location."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Internal notes."
                  },
                  "notify_lead": {
                    "type": "boolean",
                    "description": "Default true: the lead gets the confirmation email with its calendar invite plus the confirmation and reminder texts. false books quietly, and later updates or cancels stay quiet too; the host still gets the booking alert."
                  },
                  "force": {
                    "type": "boolean",
                    "description": "Skip the calendar's capacity check (the database still never double-books a person or a full calendar)."
                  }
                },
                "required": [
                  "workspace_id",
                  "starts_at"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "lead_id": "uuid",
                "calendar_id": "uuid",
                "starts_at": "2026-11-03T14:00:00Z",
                "option_id": "opt-van",
                "addon_ids": [
                  "add-pet"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/bookings/{booking_id}/reschedule": {
      "post": {
        "operationId": "reschedule_booking",
        "tags": [
          "Bookings"
        ],
        "summary": "Move an appointment",
        "description": "Re-times the reminder texts, updates the calendar mirror and the lead's invite, and fires the appointment.rescheduled outbound webhooks when the time changed. The appointment keeps its length; a full-day job runs to closing time on its new last working day. 409 slot_full when the new time is taken.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "booking_id",
            "in": "path",
            "required": true,
            "description": "Booking id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "starts_at": {
                    "type": "string",
                    "description": "New ISO start time."
                  },
                  "duration_minutes": {
                    "type": "number",
                    "description": "Optional new length, 5-1440."
                  }
                },
                "required": [
                  "starts_at"
                ],
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/bookings/{booking_id}/cancel": {
      "post": {
        "operationId": "cancel_booking",
        "tags": [
          "Bookings"
        ],
        "summary": "Cancel an appointment",
        "description": "DELETE /v1/bookings/{booking_id} does the same.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "booking_id",
            "in": "path",
            "required": true,
            "description": "Booking id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "reason": {
                    "type": "string",
                    "description": "Cancellation reason."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/bookings/{booking_id}": {
      "patch": {
        "operationId": "update_booking",
        "tags": [
          "Bookings"
        ],
        "summary": "Change an appointment's outcome, title, notes, location, host, lead notifications or lead",
        "description": "Everything but the time (use reschedule for that). status records the outcome: completed, no_show or cancelled release the lead from Booked and stop its reminder texts; confirmed puts it back on. host_user_id must be someone on the sub-account's team (GET /v1/members). notify_lead: false silences the lead's remaining reminder texts and invite updates; true turns them back on (an upcoming appointment's reminders are queued again). lead_id links an appointment that has no lead yet (typed in by hand) to a lead of the same sub-account; one that already has a lead answers 409. Linking an upcoming scheduled appointment books it for the lead like a new booking: the lead is marked booked, its follow-ups and AI calls stop, and the confirmation and reminder texts and the invite go out (unless notify_lead is false). A past or finished appointment is only linked.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "booking_id",
            "in": "path",
            "required": true,
            "description": "Booking id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "description": "The appointment's outcome.",
                    "enum": [
                      "confirmed",
                      "completed",
                      "no_show",
                      "cancelled"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "description": "Max 200."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Max 2000. null clears them."
                  },
                  "location": {
                    "type": "string",
                    "description": "Address or place, max 300. null clears it."
                  },
                  "host_user_id": {
                    "type": "string",
                    "description": "Team member who takes it. null for nobody."
                  },
                  "notify_lead": {
                    "type": "boolean",
                    "description": "false: the lead gets no more reminder texts or invite updates for this appointment. true: they do again."
                  },
                  "lead_id": {
                    "type": "string",
                    "description": "Link an appointment with no lead to this lead (same sub-account). Cannot move an appointment from one lead to another."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "status": "completed",
                "notes": "Signed the quote on site."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/members": {
      "get": {
        "operationId": "list_members",
        "tags": [
          "Members"
        ],
        "summary": "List sub-account members and invites",
        "description": "Each member has user_id, role, email and full_name. Use user_id (or the email) to name a team member in busy blocks. Staff and Technicians, who have no Team page in the app, get names and roles only (no emails, no invitations).\n\nRequired scope: `members:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "invite_member",
        "tags": [
          "Members"
        ],
        "summary": "Invite a member",
        "description": "Required scope: `members:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id."
                  },
                  "email": {
                    "type": "string",
                    "description": "Invitee email."
                  },
                  "role": {
                    "type": "string",
                    "description": "client_admin (Admin), client_viewer (Staff) or client_tech (Technician: only their own leads and appointments). Default client_viewer.",
                    "enum": [
                      "client_admin",
                      "client_viewer",
                      "client_tech"
                    ]
                  }
                },
                "required": [
                  "workspace_id",
                  "email"
                ],
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/members/{member_id}": {
      "patch": {
        "operationId": "update_member_role",
        "tags": [
          "Members"
        ],
        "summary": "Change a member's role",
        "description": "You cannot change your own role.\n\nRequired scope: `members:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "member_id",
            "in": "path",
            "required": true,
            "description": "Member id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": {
                    "type": "string",
                    "description": "client_admin (Admin), client_viewer (Staff) or client_tech (Technician: only their own leads and appointments).",
                    "enum": [
                      "client_admin",
                      "client_viewer",
                      "client_tech"
                    ]
                  }
                },
                "required": [
                  "role"
                ],
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "remove_member",
        "tags": [
          "Members"
        ],
        "summary": "Remove a member",
        "description": "Required scope: `members:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "member_id",
            "in": "path",
            "required": true,
            "description": "Member id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/smart-forms": {
      "get": {
        "operationId": "list_smart_forms",
        "tags": [
          "Smart forms"
        ],
        "summary": "List smart forms",
        "description": "Required scope: `smart_forms:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_smart_form",
        "tags": [
          "Smart forms"
        ],
        "summary": "Create a smart form",
        "description": "Starts unpublished with the same defaults as a form created in the app. The response includes its public path (/f/<slug>), qualifier_questions, custom_fields, qualification, calendar_routing, service_area and estimate. Questions can ask for photos (field_type file) and put a price on answers (option_prices) for the instant estimate: switched on with estimate, the answers' prices add up to a live total in the form's footer, saved on the lead with its total as the deal value. Qualification routes each lead to Qualified, Nurture or Not eligible: yes/no qualifier_questions (asked first when qualifier_enabled is on) and choice questions with disqualify_options or nurture_options. A service area (fields.address.service_area) only accepts addresses in chosen US states or within a radius: address suggestions stay inside it and an out-of-area visitor sees your message and cannot send the form; switching it on shows and requires the address, like the builder. Design and tracking pixels are edited in the app.\n\nRequired scope: `smart_forms:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Form name (max 80)."
                  },
                  "headline": {
                    "type": "string",
                    "description": "Max 160."
                  },
                  "subheadline": {
                    "type": "string",
                    "description": "Max 300."
                  },
                  "primary_color": {
                    "type": "string",
                    "description": "#rrggbb."
                  },
                  "bullet_points": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 8 short lines."
                  },
                  "layout_mode": {
                    "type": "string",
                    "description": "The builder's Layout: single_step (one page, the default), multi_step (a step-by-step wizard), conversational (one question at a time, like a chat) or funnel (one big question per screen).",
                    "enum": [
                      "single_step",
                      "multi_step",
                      "conversational",
                      "funnel"
                    ]
                  },
                  "calendar_id": {
                    "type": "string",
                    "description": "Calendar used by the booking step."
                  },
                  "calendar_routing": {
                    "type": "boolean",
                    "description": "Pick the calendar from the answers: the sub-account's calendar routing rules (/v1/calendar-routes) choose which calendar's times the form shows once the deciding question is answered; calendar_id is used when no rule fits."
                  },
                  "booking_enabled": {
                    "type": "boolean",
                    "description": "Show the booking step."
                  },
                  "fields": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Contact fields: {\"email\":{\"required\":false},\"address\":{\"enabled\":false}}. Keys: first_name, last_name, phone, email, address, state (a State / Province pick list), notes. Phone or email must stay on. address also takes service_area (merged): {\"enabled\":true,\"mode\":\"states\",\"states\":[\"TX\",\"OK\"],\"message\":\"Sorry, we only serve Texas and Oklahoma.\"}, or mode \"radius\" with \"center\":{\"lat\":32.7767,\"lng\":-96.797,\"label\":\"Dallas, TX\"} and \"radius_miles\" (1-500, default 25). A blank message shows \"Sorry, we don't service this area yet.\"; null or enabled:false switches it off."
                  },
                  "is_published": {
                    "type": "boolean",
                    "description": "Default false."
                  },
                  "qualifier_enabled": {
                    "type": "boolean",
                    "description": "Ask the qualifier_questions first."
                  },
                  "qualifier_questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 10, replaces the list: [{ text (max 200), disqualify_on: \"yes\" | \"no\" (default \"no\"), outcome: \"not_eligible\" | \"nurture\" (default \"not_eligible\") }]."
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Custom questions, up to 30, replaces the list: [{ key?, label (max 160), field_type: text | textarea | number | money | phone | email | url | select | multiselect | boolean | date | datetime | rating | file (photos or PDFs, up to 6, shown on the lead), options (select / multiselect: 2-40), option_prices? (select / multiselect: cents per answer for the instant estimate, e.g. {\"SUV\": 8000}; left out keeps the saved prices, null removes them), disqualify_options? or nurture_options? (choice types; boolean answers \"yes\" / \"no\"; never both), placement?: \"qualify\" | \"details\" (qualify = choice types only), option_style?: dropdown | buttons | cards | auto, no_first? (boolean: show No before Yes), required?, enabled?, save_to_crm? (never for file), placeholder?, helper_text? }]."
                  },
                  "qualification": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Merged: { save_not_eligible: boolean, nurture_page: { headline, subheadline, cta_label, cta_url, redirect_url } }."
                  },
                  "estimate": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "The instant price estimate, merged: { enabled, label (default \"Your estimate\"), base_cents (added before any answer), note (e.g. \"Final price after we see the job\"), range_percent (0-50: shown as a range that far either side) }. null switches it off."
                  }
                },
                "required": [
                  "workspace_id",
                  "name"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "name": "Roof quote",
                "qualifier_enabled": true,
                "qualifier_questions": [
                  {
                    "text": "Do you own the home?",
                    "disqualify_on": "no",
                    "outcome": "not_eligible"
                  }
                ],
                "questions": [
                  {
                    "label": "When do you want to start?",
                    "field_type": "select",
                    "options": [
                      "This month",
                      "In 1-3 months",
                      "Just researching"
                    ],
                    "nurture_options": [
                      "Just researching"
                    ],
                    "placement": "qualify"
                  },
                  {
                    "label": "Vehicle size",
                    "field_type": "select",
                    "options": [
                      "Car",
                      "SUV",
                      "Truck"
                    ],
                    "option_prices": {
                      "Car": 31500,
                      "SUV": 38500,
                      "Truck": 45000
                    }
                  },
                  {
                    "label": "Photos of the damage",
                    "field_type": "file"
                  }
                ],
                "qualification": {
                  "save_not_eligible": true
                },
                "estimate": {
                  "enabled": true,
                  "note": "Final price after we see the job",
                  "range_percent": 10
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/smart-forms/{form_id}/submissions": {
      "get": {
        "operationId": "list_form_submissions",
        "tags": [
          "Smart forms"
        ],
        "summary": "List form submissions",
        "description": "Required scope: `smart_forms:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "form_id",
            "in": "path",
            "required": true,
            "description": "Form id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Default 50.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations": {
      "get": {
        "operationId": "list_ws_automations",
        "tags": [
          "CRM automations"
        ],
        "summary": "List sub-account automations",
        "description": "Required scope: `workspace_automations:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Build an automation",
        "description": "Saved exactly as the Automations page saves it, so it opens and edits in the app. Saved OFF unless enabled is true; once on, its texts and emails go to real leads through the normal quiet hours, opt-out and daily limits. Steps can send lead data out (webhooks, alerts), so this needs an admin-scoped key. Everything it points at (stages, team members, phone numbers, review pages, Facebook pages, Smart Forms, calendars, email senders) must be in the same sub-account; GET /v1/workspace-automations/reference lists them. Any step can take a label (its name on the step card). An inbound_webhook automation comes back with its private inbound_url: POST JSON with a phone or email to start it (it must be on), and every field sent can be used in its messages as {field}.\n\nRequired scope: `workspace_automations:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Up to 80 characters."
                  },
                  "description": {
                    "type": "string",
                    "description": "Optional note."
                  },
                  "trigger": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "When it starts: {\"type\":\"new_lead\"}, {\"type\":\"stage_changed\",\"to_stages\":[\"booked\"]}, {\"type\":\"tag_added\",\"tags\":[\"hot\"]}, {\"type\":\"smart_form_submitted\",\"form_ids\":[\"Free quote\"]}, {\"type\":\"appointment_booked\",\"calendar_ids\":[\"Estimate visit\"]}, {\"type\":\"inbound_webhook\"}... Ids or names. See GET /v1/workspace-automations/reference."
                  },
                  "only_if": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Entry rules, all must hold: [{\"field\":\"tags\",\"op\":\"has_none\",\"value\":[\"customer\"]}]."
                  },
                  "steps": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "In order: [{\"action\":\"send_text\",\"message\":\"Hi {first_name}\"},{\"action\":\"wait\",\"days\":1},{\"action\":\"send_email\",\"subject\":\"Your quote\",\"message\":\"..\",\"from_sender_id\":\"<email sender id, address or name>\"},{\"action\":\"if\",\"conditions\":[..],\"then\":[..],\"else\":[..]}]. A send_text step takes send_as (auto, imessage or sms) when the sub-account has an iMessage Mac."
                  },
                  "settings": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "{\"stop_on_reply\":true,\"sending_window\":{\"days\":[\"mon\",\"tue\"],\"start\":\"09:00\",\"end\":\"18:00\"}}."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "Default false."
                  }
                },
                "required": [
                  "workspace_id",
                  "name",
                  "trigger",
                  "steps"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "name": "Speed to lead",
                "trigger": {
                  "type": "new_lead"
                },
                "steps": [
                  {
                    "action": "send_text",
                    "message": "Hi {first_name}, thanks for reaching out! When is a good time to talk?"
                  },
                  {
                    "action": "wait",
                    "days": 1
                  },
                  {
                    "action": "send_text",
                    "message": "Still interested, {first_name}?"
                  }
                ],
                "settings": {
                  "stop_on_reply": true
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/{automation_id}/enroll": {
      "post": {
        "operationId": "enroll_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Enroll leads into an automation",
        "description": "Can send real texts and emails. Confirm the lead list before calling. Leads are queued and start within the sub-account's daily contact limit. A lead already waiting in this automation's queue is not queued again (already_queued). ignore_filters defaults to false: a lead that fails the automation's only_if rules is skipped when the queue reaches it (the app's Enroll dialog defaults to true).\n\nRequired scope: `workspace_automations:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lead_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Lead ids (max 5000)."
                  },
                  "ignore_filters": {
                    "type": "boolean",
                    "description": "Default false: leads that fail the automation's only_if rules are skipped. true = enroll them anyway."
                  }
                },
                "required": [
                  "lead_ids"
                ],
                "additionalProperties": true
              },
              "example": {
                "lead_ids": [
                  "uuid"
                ],
                "ignore_filters": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "queued": 1,
                    "skipped": 0,
                    "already_queued": 0,
                    "automation": {
                      "id": "uuid",
                      "name": "Speed to lead"
                    },
                    "batch_id": "uuid"
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/{automation_id}/toggle": {
      "post": {
        "operationId": "toggle_ws_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Enable or disable a sub-account automation",
        "description": "Required scope: `workspace_automations:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "enabled": {
                    "type": "boolean",
                    "description": "Omit to flip the current state."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/reference": {
      "get": {
        "operationId": "automation_reference",
        "tags": [
          "CRM automations"
        ],
        "summary": "Every trigger, step, filter and setting the builder accepts",
        "description": "Read this before building: trigger types and their filters, step actions and their fields, entry-rule fields and operators (with every lead source), settings, message variables, and what this sub-account has for a definition to point at: stages, team, custom fields, phone numbers, review funnel, Facebook pages, Smart Forms, form names (for form_name rules), calendars and email senders.\n\nRequired scope: `workspace_automations:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/{automation_id}": {
      "get": {
        "operationId": "get_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "One automation as {trigger, only_if, steps, settings}",
        "description": "The same shape create and update take (step names included), with a ref on every step so an update can keep steps unchanged ({\"keep\":\"<ref>\"}). Webhook header values are hidden. An inbound_webhook automation includes its inbound_url; viewers see only its host, like webhook step links.\n\nRequired scope: `workspace_automations:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Change an automation",
        "description": "Send only what changes. steps replaces all steps: keep unchanged ones with {\"keep\":\"<ref>\"} from GET. settings changes only the keys sent. enabled turns it on or off.\n\nRequired scope: `workspace_automations:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "New name."
                  },
                  "trigger": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "New trigger."
                  },
                  "only_if": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "New entry rules."
                  },
                  "steps": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "New steps (replaces all)."
                  },
                  "settings": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Settings to change."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "On or off."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Delete an automation",
        "description": "Leads inside it stop where they are.\n\nRequired scope: `workspace_automations:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/{automation_id}/duplicate": {
      "post": {
        "operationId": "duplicate_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Copy an automation",
        "description": "The copy is saved OFF unless enabled is true.\n\nRequired scope: `workspace_automations:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "The copy's name."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "Default false."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/{automation_id}/enrollments": {
      "get": {
        "operationId": "list_automation_enrollments",
        "tags": [
          "CRM automations"
        ],
        "summary": "Who is inside an automation right now",
        "description": "Leads waiting on a step or mid-step, newest first, with the time their next step runs, plus how many are still waiting to be enrolled.\n\nRequired scope: `workspace_automations:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 100.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "automation": {
                      "id": "uuid",
                      "name": "Speed to lead",
                      "steps_total": 3
                    },
                    "enrollments": [
                      {
                        "run_id": "uuid",
                        "lead": {
                          "id": "uuid",
                          "full_name": "Jane Doe",
                          "phone": "+14155550123"
                        },
                        "status": "waiting",
                        "step_index": 1,
                        "started_at": "2026-09-30T14:00:00Z",
                        "next_step_at": "2026-10-01T14:00:00Z"
                      }
                    ],
                    "waiting_to_enroll": 0,
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspace-automations/{automation_id}/unenroll": {
      "post": {
        "operationId": "unenroll_automation",
        "tags": [
          "CRM automations"
        ],
        "summary": "Take leads out of an automation",
        "description": "Like Remove from workflow in the app: their run stops, queued steps (texts, emails) are cancelled and the lead's timeline notes it. Nothing is sent.\n\nRequired scope: `workspace_automations:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "automation_id",
            "in": "path",
            "required": true,
            "description": "Automation id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lead_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 500 lead ids."
                  },
                  "all": {
                    "type": "boolean",
                    "description": "true = everyone in it (instead of lead_ids)."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "lead_ids": [
                  "uuid"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "automation_id": "uuid",
                    "removed": 1,
                    "waiting_cancelled": 0
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/workflows": {
      "get": {
        "operationId": "list_lead_workflows",
        "tags": [
          "CRM automations"
        ],
        "summary": "The automations a lead is inside",
        "description": "Required scope: `workspace_automations:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead_id": "uuid",
                    "workflows": [
                      {
                        "run_id": "uuid",
                        "automation_id": "uuid",
                        "name": "Speed to lead",
                        "status": "waiting",
                        "step_index": 1,
                        "started_at": "2026-09-30T14:00:00Z",
                        "next_step_at": "2026-10-01T14:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspaces": {
      "get": {
        "operationId": "list_workspaces",
        "tags": [
          "Workspaces"
        ],
        "summary": "List sub-accounts",
        "description": "Required scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspaces/{workspace_id}": {
      "get": {
        "operationId": "get_workspace",
        "tags": [
          "Workspaces"
        ],
        "summary": "Get one sub-account",
        "description": "Required scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "path",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update_workspace",
        "tags": [
          "Workspaces"
        ],
        "summary": "Update a sub-account",
        "description": "Send only what changes: name, timezone, industry, logo_url, brand_id, archived, notify_on_appointments, enabled_features, hidden_features. logo_url is the sub-account's Client logo, the same image as Settings → Client logo & app icon: changing either changes both (null removes it). enabled_features is Settings > Features: tools only some businesses use, off until turned on (today: sales, the Sales page and the parts / tip / technician on won jobs; plans, Plans & memberships on won jobs); owners and admins. hidden_features is what the agency hides from the sub-account's own people (client admins, Staff and Technicians lose those pages, and their API keys get 403 feature_off on those routes): leads, messages, appointments, calendars, smart_forms, media, campaigns, calls, ai_voice, automations, landing_pages, invoices, sales, activity, team, ad_insights, tools, support, agent. archived, brand_id and hidden_features are the agency's: the owner or an agency admin. Both take { key: true | false } and change only the keys sent.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace_id",
            "in": "path",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "logo_url": {
                    "type": "string",
                    "description": "Client logo URL, or null to remove it."
                  },
                  "enabled_features": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Settings > Features, e.g. { \"sales\": true }."
                  },
                  "hidden_features": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Hidden from the client's people, e.g. { \"invoices\": true, \"team\": false }. Owner or agency admin."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "enabled_features": {
                  "sales": true
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/workspaces/{workspace_id}/outreach": {
      "post": {
        "operationId": "configure_outreach",
        "tags": [
          "Workspaces"
        ],
        "summary": "Configure outreach (auto-greet, AI replies, sending identity)",
        "description": "Raw column names, for anyone who can manage the sub-account; PATCH on the same path does the same. Prefer PATCH /v1/ai-texting and /v1/nurture-sequence, which take friendly names and check every value. Accepted fields: auto_greet_new_leads, first_message_template, sms_template, greet_delay_minutes_smart_form, greet_delay_minutes_default, greet_window_mode / _start / _end, followup_window_mode / _start / _end, ai_enabled, ai_system_prompt, ai_business_context, ai_agent_name, ai_booking_link, ai_max_auto_replies, reply_delay_minutes, respect_business_hours, quiet_hours_enabled / _start / _end, handoff_on_unknown, handoff_pause_ai, handoff_resume_days, ai_can_cancel_appointments, ai_cancel_retention_enabled, ai_cancel_retention_note, ai_auto_resume_minutes, nurture_enabled, nurture_steps, email_enabled, email_from_address, email_from_name, email_subject, email_template, sms_enabled, missed_call_text_enabled, missed_call_text_body, reminder_24h_enabled / _template, reminder_1h_enabled / _template, reminder_5m_enabled / _template (the 5-minute reminder, off by default), customer_confirmation_enabled / _template, appointment_email_enabled, appointment_email_language (en | es). Unknown fields are ignored; text is capped at 20,000 characters.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace_id",
            "in": "path",
            "required": true,
            "description": "Sub-account id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "auto_greet_new_leads": {
                    "type": "boolean",
                    "description": "Text new leads automatically."
                  },
                  "first_message_template": {
                    "type": "string",
                    "description": "The first text."
                  },
                  "ai_enabled": {
                    "type": "boolean",
                    "description": "AI replies on or off."
                  },
                  "ai_agent_name": {
                    "type": "string",
                    "description": "Name the AI texts as."
                  },
                  "email_from_name": {
                    "type": "string",
                    "description": "Sender name on emails."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "auto_greet_new_leads": true,
                "ai_enabled": true,
                "ai_agent_name": "Sarah"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/setup-status": {
      "get": {
        "operationId": "setup_status",
        "tags": [
          "Setup"
        ],
        "summary": "What is set up, and what is missing",
        "description": "Start here. Returns the sub-account's real configuration (numbers, AI texting, receptionist, calendars, forms, automations, offers, team, lead sources, integrations) and a severity-ranked list of findings. Each finding names the API call and MCP tool that fixes it, or says when it can only be done in the app (buying a number, SMS registration, connecting Google or Outlook).\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/offers": {
      "get": {
        "operationId": "list_offers",
        "tags": [
          "Offers"
        ],
        "summary": "List offers",
        "description": "Offers (offer playbooks) tell the AI what this business sells to a lead: the first text, the follow-up sequence, notes for the AI and the booking link.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_offer",
        "tags": [
          "Offers"
        ],
        "summary": "Create an offer",
        "description": "Required scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Internal name (max 80)."
                  },
                  "offer_label": {
                    "type": "string",
                    "description": "How the offer is described to the lead (max 200)."
                  },
                  "first_message_template": {
                    "type": "string",
                    "description": "First text to a new lead. Supports {{first_name}} (max 1600)."
                  },
                  "nurture_enabled": {
                    "type": "boolean",
                    "description": "null follows the sub-account's own follow-up setting."
                  },
                  "nurture_steps": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 12 follow-ups: { offset_minutes, body_template }. offset_minutes counts from the previous message."
                  },
                  "ai_context_note": {
                    "type": "string",
                    "description": "What the AI should know about this offer (max 2000)."
                  },
                  "booking_link": {
                    "type": "string",
                    "description": "Public http(s) URL."
                  },
                  "is_active": {
                    "type": "boolean",
                    "description": "Default true."
                  },
                  "smart_first_text_enabled": {
                    "type": "boolean",
                    "description": "true: the AI writes the first text for these leads (first_message_template is the backup); false: first_message_template goes out as written; null (default) follows the sub-account's smart first text switch."
                  },
                  "smart_first_text_instructions": {
                    "type": "string",
                    "description": "What the smart first text should do for these leads (max 1000). Empty uses the sub-account's instructions."
                  },
                  "triggers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Which leads get this offer: { type, value, label? }. type is meta_form, smart_form, webhook (a lead source id) or source (the lead's source text). Form and lead-source ids must belong to the sub-account."
                  }
                },
                "required": [
                  "workspace_id",
                  "name"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "name": "Free roof inspection",
                "offer_label": "a free 20-point roof inspection",
                "first_message_template": "Hi {{first_name}}, thanks for asking about a free roof inspection. What day works best?",
                "nurture_steps": [
                  {
                    "offset_minutes": 60,
                    "body_template": "Still want that inspection?"
                  }
                ],
                "triggers": [
                  {
                    "type": "source",
                    "value": "Website form"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/offers/{offer_id}": {
      "patch": {
        "operationId": "update_offer",
        "tags": [
          "Offers"
        ],
        "summary": "Update an offer",
        "description": "Send only what changes. `triggers`, when sent, replaces the whole list.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offer_id",
            "in": "path",
            "required": true,
            "description": "Offer id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_offer",
        "tags": [
          "Offers"
        ],
        "summary": "Delete an offer",
        "description": "Required scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "offer_id",
            "in": "path",
            "required": true,
            "description": "Offer id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendars/{calendar_id}": {
      "patch": {
        "operationId": "update_calendar",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Update a booking calendar",
        "description": "Takes the same fields as create; send only what changes. `hosts`, when sent, replaces the pool; people who stay keep their place in the rotation. An arrival_window calendar always keeps buffer_minutes at 0 (a full-day one keeps its buffer). `appointment_texts` changes only the texts it names. pricing, design and fields merge; pricing.options, pricing.addons and questions replace their lists. Turning pricing off also stops taking payment at booking.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "calendar_id",
            "in": "path",
            "required": true,
            "description": "Calendar id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "additionalProperties": true
              },
              "example": {
                "pricing": {
                  "deposit": {
                    "mode": "percent",
                    "percent": 20
                  }
                },
                "design": {
                  "colors": {
                    "button": "#d4a63a"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendars/{calendar_id}/copy-design": {
      "post": {
        "operationId": "copy_calendar_design",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Copy a calendar's design to others",
        "description": "The Design tab's \"Use on other calendars\": this calendar's design goes onto the calendars named (or every other calendar of the sub-account with all: true), switched on. A calendar that has its own cover photo keeps it. The calendar must have a design switched on.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "calendar_id",
            "in": "path",
            "required": true,
            "description": "The calendar whose design is copied.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "calendar_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The calendars to copy it to."
                  },
                  "all": {
                    "type": "boolean",
                    "description": "Every other calendar of the sub-account instead."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "all": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "from_calendar_id": "uuid",
                    "copied_to": [
                      {
                        "id": "uuid",
                        "name": "Quick wash"
                      }
                    ],
                    "design": {
                      "enabled": true,
                      "preset": "showroom",
                      "mode": "dark"
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendars/{calendar_id}/design/generate": {
      "post": {
        "operationId": "generate_calendar_design",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Design a booking page with AI",
        "description": "The Design tab's AI designer: describe the look in one line and/or give the business's website (its colours, fonts and logo are read from it). Returns the design and a one-line summary, and saves it on the calendar unless save is false. readable says whether the text reads well on the card. No credits used.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "calendar_id",
            "in": "path",
            "required": true,
            "description": "Calendar id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "instruction": {
                    "type": "string",
                    "description": "What it should look like, e.g. \"black and gold, like a luxury showroom\" (max 1200)."
                  },
                  "website_url": {
                    "type": "string",
                    "description": "The business's website."
                  },
                  "save": {
                    "type": "boolean",
                    "description": "Default true. false only returns the design (send it later with PATCH design)."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "instruction": "black and gold, like a luxury showroom",
                "website_url": "https://example.com"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "design": {
                      "enabled": true,
                      "preset": null,
                      "mode": "dark",
                      "colors": {
                        "background": "#09090b",
                        "surface": "#141416",
                        "text": "#f5f5f4",
                        "button": "#d4a63a"
                      },
                      "font": "montserrat",
                      "heading_font": "oswald",
                      "radius": "soft",
                      "button_style": "solid",
                      "backdrop": "glow",
                      "logo_url": null,
                      "cover_url": null,
                      "hide_avatar": false,
                      "custom_css": null
                    },
                    "summary": "Dark showroom look with gold buttons and condensed headings.",
                    "saved": true,
                    "website": {
                      "url": "https://example.com",
                      "read": true
                    },
                    "readable": true
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/booking-menus": {
      "get": {
        "operationId": "list_booking_menus",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "List service menus",
        "description": "Service menus (Calendars → Booking tools → Service menu): one booking link (/c/<slug>, public_path) that lists several calendars in sections, with search, category chips and sorting; the customer picks a service and books it there. Each section lists its services with their price and length as the page shows them. warnings says when its services are on separate schedules (two customers could book the same time on different services) or switched off.\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "booking_menus": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "slug": "to-the-t-services",
                        "name": "All services",
                        "title": "Book a detail",
                        "description": null,
                        "sections": [
                          {
                            "id": "sec1",
                            "title": "Quick Services",
                            "description": null,
                            "calendar_ids": [
                              "uuid"
                            ],
                            "services": [
                              {
                                "calendar_id": "uuid",
                                "name": "Express wash",
                                "title": "Express wash",
                                "is_active": true,
                                "price_from_cents": 6000,
                                "price_to_cents": 9000,
                                "length_label": "1-2 hr",
                                "schedule_group": "Main crew"
                              }
                            ]
                          }
                        ],
                        "options": {
                          "show_prices": true,
                          "show_durations": true,
                          "search": true,
                          "filters": true,
                          "sorting": true,
                          "default_sort": "featured"
                        },
                        "design": null,
                        "is_active": true,
                        "public_path": "/c/to-the-t-services",
                        "warnings": [],
                        "created_at": "2026-10-23T12:00:00Z",
                        "updated_at": "2026-10-23T12:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_booking_menu",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Create a service menu",
        "description": "Without sections it starts like the app's: one \"Services\" section with every calendar that is switched on, and a link named after the business. The link shares /c/ with calendars, so a slug a calendar or another menu uses answers 409.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "title": {
                    "type": "string",
                    "description": "Heading customers see (max 120). Default \"Book a service\"."
                  },
                  "name": {
                    "type": "string",
                    "description": "Internal name (max 80). Default \"All services\"."
                  },
                  "description": {
                    "type": "string",
                    "description": "Under the heading (max 600)."
                  },
                  "slug": {
                    "type": "string",
                    "description": "Link name: /c/<slug> (letters, numbers, dashes; max 40)."
                  },
                  "sections": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "In order, replacing the list: [{ id?, title (max 80), description?, calendar_ids: [calendar ids, in the order shown] }]. Up to 30 sections; every calendar must belong to the sub-account."
                  },
                  "options": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Merged: { show_prices, show_durations, search, filters (category chips), sorting, default_sort: featured | price_low | price_high | shortest | name }. All on by default."
                  },
                  "design": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "The page look, the same shape as a calendar's design. It carries into each service's booking flow opened from the menu."
                  },
                  "is_active": {
                    "type": "boolean",
                    "description": "Default true."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "title": "Book a detail",
                "sections": [
                  {
                    "title": "Quick Services",
                    "calendar_ids": [
                      "uuid",
                      "uuid"
                    ]
                  },
                  {
                    "title": "Detailing Packages",
                    "calendar_ids": [
                      "uuid"
                    ]
                  }
                ],
                "design": {
                  "preset": "showroom"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/booking-menus/{menu_id}": {
      "patch": {
        "operationId": "update_booking_menu",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Update a service menu",
        "description": "Takes the same fields as create; send only what changes. sections replaces the list; options and design merge.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "menu_id",
            "in": "path",
            "required": true,
            "description": "Menu id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {},
                "additionalProperties": true
              },
              "example": {
                "options": {
                  "default_sort": "price_low"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_booking_menu",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Delete a service menu",
        "description": "Its link stops working; the calendars on it are not touched.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "menu_id",
            "in": "path",
            "required": true,
            "description": "Menu id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/booking-menus/{menu_id}/share-schedule": {
      "post": {
        "operationId": "share_menu_schedule",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Put a menu's services on one schedule",
        "description": "The menu editor's \"Share one schedule\": every calendar on the menu gets the same schedule_group, so a booking on any of them takes that time on all of them (one crew doing every service). group names it; by default the group one of them already has, else the menu's title.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "menu_id",
            "in": "path",
            "required": true,
            "description": "Menu id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "group": {
                    "type": "string",
                    "description": "The shared schedule's name (max 60)."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "schedule_group": "Main crew",
                    "calendar_ids": [
                      "uuid",
                      "uuid"
                    ],
                    "changed": [
                      "uuid"
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/booking-menus/{menu_id}/design/generate": {
      "post": {
        "operationId": "generate_menu_design",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Design a service menu with AI",
        "description": "Same as POST /v1/calendars/{calendar_id}/design/generate, for a service menu's page.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "menu_id",
            "in": "path",
            "required": true,
            "description": "Menu id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "instruction": {
                    "type": "string",
                    "description": "What it should look like."
                  },
                  "website_url": {
                    "type": "string",
                    "description": "The business's website."
                  },
                  "save": {
                    "type": "boolean",
                    "description": "Default true."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/availability": {
      "get": {
        "operationId": "get_availability",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Get business hours and booking defaults",
        "description": "Required scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "operationId": "set_availability",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Set business hours and booking defaults",
        "description": "The AI uses these to decide when it may text and which times to offer. Setting the time zone also updates the sub-account's time zone.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA zone."
                  },
                  "weekly_hours": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Same shape as a calendar's."
                  },
                  "date_overrides": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Days off or special hours."
                  },
                  "slot_minutes": {
                    "type": "number",
                    "description": "5-240."
                  },
                  "buffer_minutes": {
                    "type": "number",
                    "description": "0-120. Always saved as 0 when scheduling_mode is arrival_window."
                  },
                  "default_calendar_id": {
                    "type": "string",
                    "description": "A calendar of this sub-account, or null."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "timezone": "America/Chicago",
                "weekly_hours": {
                  "mon": [
                    [
                      "08:00",
                      "17:00"
                    ]
                  ],
                  "sat": [
                    [
                      "09:00",
                      "13:00"
                    ]
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendar-routes": {
      "get": {
        "operationId": "list_calendar_routes",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "List calendar routing rules",
        "description": "Calendar routing (Calendars -> Calendar routing in the app) sends each lead to the calendar that fits their answers: \"Player group is Girls 13-14 -> Girls 13-14 calendar\". Rules are checked in order (`position` 1 first); the first rule whose conditions ALL match the lead's custom fields or tags picks the calendar. Smart Forms with calendar_routing on, the AI texter and the AI caller follow them. Each rule comes with its calendar's name and a readable `summary`. Rules that are switched off, or whose calendar is off, are skipped.\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "calendar_routes": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "calendar_id": "uuid",
                        "calendar_name": "Girls 13-14",
                        "calendar_active": true,
                        "name": "Girls 13-14",
                        "conditions": [
                          {
                            "kind": "field",
                            "key": "player_group",
                            "op": "is",
                            "values": [
                              "Girls 13-14"
                            ],
                            "min": null,
                            "max": null
                          }
                        ],
                        "summary": "Player group is Girls 13-14",
                        "position": 1,
                        "is_active": true,
                        "created_at": "2026-10-07T18:00:00Z",
                        "updated_at": "2026-10-07T18:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_calendar_route",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Add a calendar routing rule",
        "description": "Added last unless you send `position`. Conditions: a field condition reads a custom field by key (GET /v1/custom-fields) with op is, is_not or contains and `values` (any one matches), or op between with min and/or max for numbers (\"11 years old\" counts as 11); a tag condition (kind tag, op is or is_not) reads the lead's tags. Answers compare ignoring case, accents and punctuation. The calendar must belong to the sub-account. `warnings` explains a rule that may never fire (a key that is not a custom field, a calendar that is switched off). Owners and admins only; at most 200 rules.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "calendar_id": {
                    "type": "string",
                    "description": "The calendar this rule books on (GET /v1/calendars)."
                  },
                  "conditions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "All must match, 1-20: [{\"kind\":\"field\",\"key\":\"player_group\",\"op\":\"is\",\"values\":[\"Girls 13-14\"]}], [{\"kind\":\"field\",\"key\":\"age\",\"op\":\"between\",\"min\":9,\"max\":12}], [{\"kind\":\"tag\",\"op\":\"is\",\"values\":[\"VIP\"]}]."
                  },
                  "name": {
                    "type": "string",
                    "description": "Optional label, max 120."
                  },
                  "is_active": {
                    "type": "boolean",
                    "description": "Default true."
                  },
                  "position": {
                    "type": "number",
                    "description": "1 = checked first. Default last."
                  }
                },
                "required": [
                  "workspace_id",
                  "calendar_id",
                  "conditions"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "calendar_id": "uuid",
                "name": "Girls 13-14",
                "conditions": [
                  {
                    "kind": "field",
                    "key": "player_group",
                    "op": "is",
                    "values": [
                      "Girls 13-14"
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "calendar_route": {
                      "id": "uuid",
                      "workspace_id": "uuid",
                      "calendar_id": "uuid",
                      "calendar_name": "Girls 13-14",
                      "calendar_active": true,
                      "name": "Girls 13-14",
                      "conditions": [
                        {
                          "kind": "field",
                          "key": "player_group",
                          "op": "is",
                          "values": [
                            "Girls 13-14"
                          ],
                          "min": null,
                          "max": null
                        }
                      ],
                      "summary": "Player group is Girls 13-14",
                      "position": 3,
                      "is_active": true,
                      "created_at": "2026-10-16T18:00:00Z",
                      "updated_at": "2026-10-16T18:00:00Z"
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendar-routes/{route_id}": {
      "patch": {
        "operationId": "update_calendar_route",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Change a calendar routing rule",
        "description": "Send any of calendar_id, name, conditions (replaces the list) and is_active. To move a rule use POST /v1/calendar-routes/reorder. Owners and admins only.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "route_id",
            "in": "path",
            "required": true,
            "description": "Rule id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "calendar_id": {
                    "type": "string",
                    "description": "Another calendar of the sub-account."
                  },
                  "conditions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Replaces the conditions (see create)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Max 120."
                  },
                  "is_active": {
                    "type": "boolean",
                    "description": "false keeps the rule but skips it."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "is_active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_calendar_route",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Delete a calendar routing rule",
        "description": "Owners and admins only. The other rules keep their order.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "route_id",
            "in": "path",
            "required": true,
            "description": "Rule id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendar-routes/reorder": {
      "post": {
        "operationId": "reorder_calendar_routes",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Set the order rules are checked in",
        "description": "The first rule that matches wins, so put narrower rules first. `order` lists every rule id of the sub-account exactly once, first to last. Answers the rules in their new order. Owners and admins only.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "order": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Every rule id, first to last."
                  }
                },
                "required": [
                  "workspace_id",
                  "order"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "order": [
                  "uuid-rule-b",
                  "uuid-rule-a"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calendar-routes/match": {
      "get": {
        "operationId": "match_calendar_route",
        "tags": [
          "Calendars & hours"
        ],
        "summary": "Which calendar a lead routes to",
        "description": "Runs the rules the way the booking paths do (active rules on calendars that are on) against a lead's custom fields and tags, and/or `answers` you pass. status: matched (`calendar` and the `route` that won), pending (no rule matched yet but one still can: `missing_fields` are the answers to ask for before offering times), unmatched (no rule fits: the form's or the AI's own calendar applies), or no_rules. Viewers limited to their own leads only reach those leads.\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": false,
            "description": "Sub-account id (omit on pinned keys). Needed without lead_id; with lead_id, the lead must be in it.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "The lead to route. Send lead_id, answers or both.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "answers",
            "in": "query",
            "required": false,
            "description": "JSON object of field key to answer to try, laid over the lead's own, e.g. {\"player_group\":\"Girls 13-14\"}.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead_id": "uuid",
                    "status": "pending",
                    "calendar": null,
                    "route": null,
                    "missing_fields": [
                      {
                        "key": "player_group",
                        "label": "Player group"
                      }
                    ],
                    "rules_checked": 4
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/busy-blocks/{external_id}": {
      "put": {
        "operationId": "put_busy_block",
        "tags": [
          "Team busy times"
        ],
        "summary": "Add or update a team member's busy block",
        "description": "For a schedule kept in other software (a field-service app, a dispatch board): the person is treated as booked for that time, so the AI (text, chat and phone), Smart Forms, booking pages and round robin only offer times when they are free. `external_id` is YOUR id for the block (a job or visit id, URL-encoded in the path); sending the same id again replaces the block, so it is safe to resend. A block can make several people busy (a two-tech job). Team members are named by user id or email (GET /v1/members); technicians must be invited as members first. Times need a time zone (Z or an offset). At most 31 days per block. 201 when created, 200 when replaced (changed: false when nothing differed). Owners and admins of the sub-account only.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "external_id",
            "in": "path",
            "required": true,
            "description": "Your own id for the block: 1-200 letters, digits or . _ : ~ @ # | + = -",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "team_member": {
                    "type": "string",
                    "description": "The busy person: a team member's user id or email. Or team_members for several."
                  },
                  "team_members": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Several busy people (user ids or emails), up to 50."
                  },
                  "starts_at": {
                    "type": "string",
                    "description": "ISO 8601 with a zone, e.g. 2026-10-14T08:00:00-05:00."
                  },
                  "ends_at": {
                    "type": "string",
                    "description": "ISO 8601 with a zone; after starts_at."
                  },
                  "title": {
                    "type": "string",
                    "description": "Optional note shown to the team in the CRM calendar (never to leads or the AI), max 200."
                  }
                },
                "required": [
                  "workspace_id",
                  "starts_at",
                  "ends_at"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "team_member": "tech.alex@example.com",
                "starts_at": "2026-10-14T08:00:00-05:00",
                "ends_at": "2026-10-14T11:30:00-05:00",
                "title": "Job #4821 water heater install"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "busy_block": {
                      "id": "uuid",
                      "external_id": "job-4821",
                      "team_members": [
                        {
                          "id": "uuid",
                          "email": "tech.alex@example.com",
                          "name": "Alex Rivera"
                        }
                      ],
                      "starts_at": "2026-10-14T13:00:00.000Z",
                      "ends_at": "2026-10-14T16:30:00.000Z",
                      "title": "Job #4821 water heater install",
                      "source": "api",
                      "created_at": "2026-10-09T15:02:11Z",
                      "updated_at": "2026-10-09T15:02:11Z"
                    },
                    "created": true,
                    "changed": true
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_busy_block",
        "tags": [
          "Team busy times"
        ],
        "summary": "Remove a busy block",
        "description": "By your own id; the time opens up again at once. 404 when there is no block with that id.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "external_id",
            "in": "path",
            "required": true,
            "description": "Your id for the block (URL-encoded).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/busy-blocks": {
      "get": {
        "operationId": "list_busy_blocks",
        "tags": [
          "Team busy times"
        ],
        "summary": "List busy blocks",
        "description": "Blocks that overlap the window, earliest first. Default window: from yesterday, 60 days long; at most 366 days.\n\nRequired scope: `bookings:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "team_member",
            "in": "query",
            "required": false,
            "description": "Only this person's blocks (user id or email).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "ISO start with a zone.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "ISO end with a zone.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-500, default 100.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "description": "Skip this many (has_more says whether there are more).",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/busy-blocks/sync": {
      "post": {
        "operationId": "sync_busy_blocks",
        "tags": [
          "Team busy times"
        ],
        "summary": "Sync a time window in one call",
        "description": "Send your full list of busy blocks for a window: blocks in the list are added or replaced, and blocks you sent earlier that START inside [from, to) but are no longer in the list are removed (cancelled or moved jobs). With team_member, only that person's blocks are replaced and each block defaults to them; a removed block that also names other people keeps them. Up to 500 blocks per call. Good for a nightly or hourly full sync next to the per-block calls. Owners and admins only.\n\nRequired scope: `bookings:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "from": {
                    "type": "string",
                    "description": "Window start, ISO 8601 with a zone."
                  },
                  "to": {
                    "type": "string",
                    "description": "Window end; at most 366 days after from."
                  },
                  "team_member": {
                    "type": "string",
                    "description": "Sync one person only (user id or email)."
                  },
                  "blocks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "[{ external_id, team_member | team_members, starts_at, ends_at, title? }]. [] clears the window."
                  }
                },
                "required": [
                  "workspace_id",
                  "from",
                  "to",
                  "blocks"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "from": "2026-10-13T00:00:00-05:00",
                "to": "2026-10-20T00:00:00-05:00",
                "team_member": "tech.alex@example.com",
                "blocks": [
                  {
                    "external_id": "job-4821",
                    "starts_at": "2026-10-14T08:00:00-05:00",
                    "ends_at": "2026-10-14T11:30:00-05:00"
                  },
                  {
                    "external_id": "pto-2210",
                    "starts_at": "2026-10-17T00:00:00-05:00",
                    "ends_at": "2026-10-18T00:00:00-05:00",
                    "title": "Day off"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "created": 1,
                    "updated": 0,
                    "unchanged": 1,
                    "removed": 2,
                    "window": {
                      "from": "2026-10-13T05:00:00.000Z",
                      "to": "2026-10-20T05:00:00.000Z"
                    },
                    "team_member": {
                      "id": "uuid",
                      "email": "tech.alex@example.com",
                      "name": "Alex Rivera"
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/stages/{stage_id}": {
      "patch": {
        "operationId": "update_stage",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Rename, recolour or hide a stage",
        "description": "The five built-in stages (new, contacted, booked, won, lost) can only change label, color and hidden.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage_id",
            "in": "path",
            "required": true,
            "description": "Stage id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_stage",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Delete a custom stage",
        "description": "Its leads move to the stage named in move_to. Built-in stages cannot be deleted; hide them instead.\n\nRequired scope: `leads:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage_id",
            "in": "path",
            "required": true,
            "description": "Stage id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "move_to",
            "in": "query",
            "required": true,
            "description": "Key of the stage that takes over the leads.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/stages/reorder": {
      "post": {
        "operationId": "reorder_stages",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Reorder the pipeline",
        "description": "Required scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "order": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Every stage id of the sub-account, first to last."
                  }
                },
                "required": [
                  "workspace_id",
                  "order"
                ],
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/custom-fields": {
      "get": {
        "operationId": "list_custom_fields",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "List custom lead fields",
        "description": "Required scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_archived",
            "in": "query",
            "required": false,
            "description": "Include archived fields.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_custom_field",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Add a custom lead field",
        "description": "field_key and field_type cannot change later, because stored lead values depend on them.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "label": {
                    "type": "string",
                    "description": "Field label (max 80)."
                  },
                  "field_type": {
                    "type": "string",
                    "description": "Default text.",
                    "enum": [
                      "text",
                      "textarea",
                      "number",
                      "money",
                      "phone",
                      "email",
                      "select",
                      "date",
                      "datetime",
                      "url",
                      "boolean",
                      "rating",
                      "multiselect"
                    ]
                  },
                  "field_key": {
                    "type": "string",
                    "description": "Defaults to a key made from the label."
                  },
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Choices for select / multiselect."
                  },
                  "required": {
                    "type": "boolean",
                    "description": "Default false."
                  },
                  "show_in_list": {
                    "type": "boolean",
                    "description": "Show as a column in the leads list."
                  }
                },
                "required": [
                  "workspace_id",
                  "label"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "label": "Roof type",
                "field_type": "select",
                "options": [
                  "Shingle",
                  "Metal",
                  "Tile"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/custom-fields/{field_id}": {
      "patch": {
        "operationId": "update_custom_field",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Update a custom field",
        "description": "Send `archived: false` to restore an archived field.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "field_id",
            "in": "path",
            "required": true,
            "description": "Field id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "archive_custom_field",
        "tags": [
          "Pipeline & fields"
        ],
        "summary": "Archive a custom field",
        "description": "Hides the field. Values already stored on leads are kept.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "field_id",
            "in": "path",
            "required": true,
            "description": "Field id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/lead-routing": {
      "get": {
        "operationId": "get_lead_routing",
        "tags": [
          "Routing & alerts"
        ],
        "summary": "Get lead round-robin settings",
        "description": "Required scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "operationId": "set_lead_routing",
        "tags": [
          "Routing & alerts"
        ],
        "summary": "Set lead round-robin settings",
        "description": "Assigns NEW LEADS to team members in turn. (A round-robin calendar is separate: it rotates appointment hosts.) An empty eligible_member_ids list means everyone takes turns. member_weights splits leads by percentage (80/20 gives one person 8 of every 10 leads, spread out); {} goes back to even turns.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "round_robin_enabled": {
                    "type": "boolean",
                    "description": "Turn the rotation on or off."
                  },
                  "eligible_member_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "User ids from GET /v1/members. Empty = everyone."
                  },
                  "member_weights": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Percentage split by user id (GET /v1/members): {\"<user_id>\": 80, \"<other_user_id>\": 20}. Whole percents 0-100; the shares above 0 must add up to exactly 100. Sets eligible_member_ids to the people with a share and restarts the rotation. {} = even turns (keeps who is in the rotation)."
                  },
                  "notify_assignee_only": {
                    "type": "boolean",
                    "description": "Alert only the person the lead went to."
                  },
                  "skip_imported_leads": {
                    "type": "boolean",
                    "description": "Leave imported leads unassigned."
                  },
                  "notify_on_reply": {
                    "type": "boolean",
                    "description": "Alert the assignee when the lead replies."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "round_robin_enabled": true,
                "member_weights": {
                  "user-uuid-a": 80,
                  "user-uuid-b": 20
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/alert-recipients": {
      "get": {
        "operationId": "list_alert_recipients",
        "tags": [
          "Routing & alerts"
        ],
        "summary": "List who is alerted about new leads and AI receptionist calls",
        "description": "Required scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_alert_recipient",
        "tags": [
          "Routing & alerts"
        ],
        "summary": "Add a lead alert recipient",
        "description": "Lead details are sent to this phone or inbox, so this needs an admin-scoped key.\n\nRequired scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "channel": {
                    "type": "string",
                    "description": "sms or email.",
                    "enum": [
                      "sms",
                      "email"
                    ]
                  },
                  "destination": {
                    "type": "string",
                    "description": "Phone (US 10-digit or +country code; stored as E.164) or email address."
                  },
                  "label": {
                    "type": "string",
                    "description": "e.g. Owner's cell."
                  },
                  "notify_leads": {
                    "type": "boolean",
                    "description": "Gets new-lead, appointment and reply alerts. Default true."
                  },
                  "notify_calls": {
                    "type": "boolean",
                    "description": "Gets a summary after every AI receptionist call (who called, the outcome, any message or booking, the transcript). Default false."
                  }
                },
                "required": [
                  "workspace_id",
                  "channel",
                  "destination"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "channel": "sms",
                "destination": "+14155550123",
                "label": "Owner"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/alert-recipients/{recipient_id}": {
      "patch": {
        "operationId": "update_alert_recipient",
        "tags": [
          "Routing & alerts"
        ],
        "summary": "Update a lead alert recipient",
        "description": "Send any of label, destination, active, notify_leads, notify_calls. A recipient keeps at least one of notify_leads or notify_calls.\n\nRequired scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "recipient_id",
            "in": "path",
            "required": true,
            "description": "Recipient id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_alert_recipient",
        "tags": [
          "Routing & alerts"
        ],
        "summary": "Remove a lead alert recipient",
        "description": "Required scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "recipient_id",
            "in": "path",
            "required": true,
            "description": "Recipient id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/lead-sources": {
      "get": {
        "operationId": "list_lead_sources",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "List lead source links",
        "description": "Each link is a private URL that accepts leads, so reading them takes write scope. Treat the URL as a secret.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_lead_source",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "Create a lead source link",
        "description": "Returns a URL any website form, landing page tool or CRM can POST leads (or appointments) to.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "e.g. Website contact form."
                  },
                  "field_mapping": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Their field name to ours: {\"Full Name\":\"full_name\",\"Roof size\":\"custom:roof_size\"}. Targets: full_name, email, phone, address, city, state, zip, inquiry, notes, appointment_* or custom:<field_key>. A state is saved as its code (\"Texas\" becomes TX)."
                  },
                  "default_source": {
                    "type": "string",
                    "description": "Source label stamped on these leads."
                  },
                  "default_status": {
                    "type": "string",
                    "description": "Default new."
                  },
                  "payload_kind": {
                    "type": "string",
                    "description": "Default auto. update = a form your own team fills in (e.g. during a call): its answers go onto the matching contact (lead_id, phone, then email; added quietly when nobody matches) and nothing is sent: no first text, team alert, Instant Lead Connect call or new-lead automation.",
                    "enum": [
                      "auto",
                      "lead",
                      "appointment",
                      "update"
                    ]
                  }
                },
                "required": [
                  "workspace_id",
                  "name"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "name": "Website contact form",
                "default_source": "Website",
                "field_mapping": {
                  "Your name": "full_name",
                  "Phone number": "phone"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/lead-sources/{lead_source_id}": {
      "patch": {
        "operationId": "update_lead_source",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "Update a lead source link",
        "description": "Links created by an integration (for example Typeform) are managed there and answer 409.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_source_id",
            "in": "path",
            "required": true,
            "description": "Lead source id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_lead_source",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "Delete a lead source link",
        "description": "Required scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_source_id",
            "in": "path",
            "required": true,
            "description": "Lead source id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/outbound-webhooks": {
      "get": {
        "operationId": "list_outbound_webhooks",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "List outbound webhooks",
        "description": "Never returns signing secrets or auth tokens.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_outbound_webhook",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "Create an outbound webhook",
        "description": "Pushes lead and appointment events to another system (Zapier, Make, a CRM). Lead data leaves the account, so every write needs an admin-scoped key and target_url must be https on a public host. The signing secret is returned once.\n\nRequired scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "e.g. Zapier: new leads."
                  },
                  "target_url": {
                    "type": "string",
                    "description": "https:// URL that receives the POST."
                  },
                  "events": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Default lead.created and appointment.booked. See the sub-account webhook events list."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "Default true."
                  },
                  "preset": {
                    "type": "string",
                    "description": "Payload flavour.",
                    "enum": [
                      "zapier",
                      "make",
                      "salesforce_flow",
                      "service_titan",
                      "custom"
                    ]
                  },
                  "auth_type": {
                    "type": "string",
                    "description": "Default none. Send auth_token (and auth_header_name or auth_username) with it. Write-only.",
                    "enum": [
                      "none",
                      "bearer",
                      "header",
                      "basic"
                    ]
                  }
                },
                "required": [
                  "workspace_id",
                  "name",
                  "target_url"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "name": "Zapier: new leads",
                "target_url": "https://hooks.zapier.com/hooks/catch/123/abc/",
                "events": [
                  "lead.created"
                ],
                "preset": "zapier"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/outbound-webhooks/{webhook_id}": {
      "patch": {
        "operationId": "update_outbound_webhook",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "Update an outbound webhook",
        "description": "Required scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "description": "Webhook id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_outbound_webhook",
        "tags": [
          "Lead sources & webhooks"
        ],
        "summary": "Delete an outbound webhook",
        "description": "Required scope: `workspaces:admin`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "description": "Webhook id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/knowledge-base": {
      "get": {
        "operationId": "get_knowledge_base",
        "tags": [
          "AI agent"
        ],
        "summary": "Read the AI's FAQ",
        "description": "Required scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "operationId": "set_knowledge_base",
        "tags": [
          "AI agent"
        ],
        "summary": "Replace the AI's FAQ",
        "description": "The FAQ is what the AI texting agent and AI receptionist answer from. Max 200 entries (question 300 characters, answer 2000).\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "entries": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "[{ question, answer }]. Replaces the whole list."
                  }
                },
                "required": [
                  "workspace_id",
                  "entries"
                ],
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "add_knowledge_base",
        "tags": [
          "AI agent"
        ],
        "summary": "Add FAQ entries",
        "description": "Merges into the existing list. The same question again replaces its answer.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "entries": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "[{ question, answer }]."
                  }
                },
                "required": [
                  "workspace_id",
                  "entries"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "entries": [
                  {
                    "question": "Do you offer financing?",
                    "answer": "Yes, 0% for 12 months on approved credit."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-brain/photos": {
      "get": {
        "operationId": "list_brain_photos",
        "tags": [
          "AI agent"
        ],
        "summary": "AI Brain photos",
        "description": "Photos of the business's work the AI may text a customer who asks to see some (up to 100): link, caption, the service it shows, on / off, how often it was sent. Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "Only on (true) or off (false).",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "add_brain_photo",
        "tags": [
          "AI agent"
        ],
        "summary": "Add an AI Brain photo",
        "description": "From a public link to a JPEG, PNG or WebP (10 MB at most), stored like an upload on the page. The AI writes the caption and service you leave out, which is how it picks the right photo. 409 at 100 photos.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "image_url": {
                    "type": "string",
                    "description": "Public link to the image."
                  },
                  "caption": {
                    "type": "string",
                    "description": "What it shows (max 300)."
                  },
                  "service": {
                    "type": "string",
                    "description": "The service (max 80), e.g. Roof repair."
                  },
                  "active": {
                    "type": "boolean",
                    "description": "Default true."
                  }
                },
                "required": [
                  "workspace_id",
                  "image_url"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "image_url": "https://example.com/jobs/roof-after.jpg",
                "service": "Roof repair"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-brain/photos/{photo_id}": {
      "patch": {
        "operationId": "update_brain_photo",
        "tags": [
          "AI agent"
        ],
        "summary": "Change an AI Brain photo",
        "description": "Required scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "photo_id",
            "in": "path",
            "required": true,
            "description": "Photo id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "caption": {
                    "type": "string",
                    "description": "What it shows (max 300)."
                  },
                  "service": {
                    "type": "string",
                    "description": "The service it shows (max 80)."
                  },
                  "active": {
                    "type": "boolean",
                    "description": "Off: the AI stops sending it."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_brain_photo",
        "tags": [
          "AI agent"
        ],
        "summary": "Remove an AI Brain photo",
        "description": "Required scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "photo_id",
            "in": "path",
            "required": true,
            "description": "Photo id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-brain/waiting": {
      "get": {
        "operationId": "list_brain_waiting",
        "tags": [
          "AI agent"
        ],
        "summary": "Questions waiting on you",
        "description": "AI Brain > Waiting on you: questions customers asked (texts, chat, DMs, calls) that the AI couldn't answer and handed to the team, newest first, one row per question (times = how many customers asked, variants = how they wrote it). Answered and dismissed ones are left out. Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "waiting": [
                      {
                        "event_id": "uuid",
                        "event_ids": [
                          "uuid",
                          "uuid"
                        ],
                        "variants": [
                          "Do you work on Sundays?",
                          "Are you open Sunday?"
                        ],
                        "lead_id": "uuid",
                        "lead_name": "Jane Doe",
                        "question": "Do you work on Sundays?",
                        "asked_at": "2026-10-24T18:02:00Z",
                        "times": 2,
                        "channel": "sms"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-brain/waiting/answer": {
      "post": {
        "operationId": "answer_brain_waiting",
        "tags": [
          "AI agent"
        ],
        "summary": "Answer a waiting question",
        "description": "As Answer it on the page: the answer becomes a saved answer (replacing one to the same question) that the AI texter and receptionist use from now on, the question leaves the list, and the AI turns back on for the leads it was paused on for that question. Nothing is sent to the customer.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "question": {
                    "type": "string",
                    "description": "The question as listed."
                  },
                  "answer": {
                    "type": "string",
                    "description": "What the AI should say (max 2000)."
                  },
                  "event_id": {
                    "type": "string",
                    "description": "The row's event_id."
                  }
                },
                "required": [
                  "workspace_id",
                  "question",
                  "answer"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "event_id": "uuid",
                "question": "Do you work on Sundays?",
                "answer": "No, we're open Monday to Saturday, 8 to 6."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "saved": true,
                    "ok": true,
                    "replaced": false,
                    "entries": 18,
                    "resumed_lead_ids": [
                      "uuid"
                    ],
                    "still_waiting": 0
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-brain/waiting/dismiss": {
      "post": {
        "operationId": "dismiss_brain_waiting",
        "tags": [
          "AI agent"
        ],
        "summary": "Dismiss waiting questions",
        "description": "Takes questions off the list without teaching the AI (it still treats them as open); undo: true puts them back.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "event_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "The rows' event_ids."
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Or the questions themselves."
                  },
                  "undo": {
                    "type": "boolean",
                    "description": "Put them back."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-receptionist": {
      "get": {
        "operationId": "get_ai_receptionist",
        "tags": [
          "AI agent"
        ],
        "summary": "Read the AI receptionist settings",
        "description": "Also returns the list of voices, and collect_fields as a list of keys.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "operationId": "set_ai_receptionist",
        "tags": [
          "AI agent"
        ],
        "summary": "Configure the AI receptionist",
        "description": "The AI that answers the sub-account's phone. Answered calls bill 1.5 credits per minute of AI conversation (15-second steps; time after a transfer to a person bills as phone minutes), and it needs a phone number on the sub-account to do anything (the response carries a warning when there is none).\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "Turn it on or off."
                  },
                  "mode": {
                    "type": "string",
                    "description": "Every call, or only outside business hours.",
                    "enum": [
                      "always",
                      "after_hours"
                    ]
                  },
                  "goal": {
                    "type": "string",
                    "description": "What it tries to do.",
                    "enum": [
                      "book",
                      "support",
                      "book_and_support"
                    ]
                  },
                  "agent_name": {
                    "type": "string",
                    "description": "Max 40."
                  },
                  "voice": {
                    "type": "string",
                    "description": "One of the voices returned by GET."
                  },
                  "greeting": {
                    "type": "string",
                    "description": "Max 400."
                  },
                  "after_hours_greeting": {
                    "type": "string",
                    "description": "Max 400."
                  },
                  "extra_instructions": {
                    "type": "string",
                    "description": "Max 1200."
                  },
                  "transfer_enabled": {
                    "type": "boolean",
                    "description": "Allow transfers to a person."
                  },
                  "transfer_numbers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Up to 8 phone numbers."
                  },
                  "take_messages": {
                    "type": "boolean",
                    "description": "Take a message when nobody is available."
                  },
                  "max_call_seconds": {
                    "type": "number",
                    "description": "60-1800."
                  },
                  "record_calls": {
                    "type": "boolean",
                    "description": "Record answered calls (billed per recorded minute)."
                  },
                  "update_contact_details": {
                    "type": "boolean",
                    "description": "Let it save the caller's name, email and address to the lead."
                  },
                  "collect_fields": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Details it asks for before booking: \"address\", \"email\" or custom field keys (GET /v1/custom-fields). Max 12."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "enabled": true,
                "mode": "after_hours",
                "goal": "book_and_support",
                "agent_name": "Ava",
                "collect_fields": [
                  "address",
                  "roof_type"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/smart-forms/{form_id}": {
      "patch": {
        "operationId": "update_smart_form",
        "tags": [
          "Smart forms"
        ],
        "summary": "Update or publish a smart form",
        "description": "Takes the same fields as create; send only what changes. questions and qualifier_questions replace their lists; qualification, estimate, fields and fields.address.service_area are merged.\n\nRequired scope: `smart_forms:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "form_id",
            "in": "path",
            "required": true,
            "description": "Form id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "is_published": {
                    "type": "boolean",
                    "description": "Publish or unpublish."
                  },
                  "layout_mode": {
                    "type": "string",
                    "description": "single_step, multi_step, conversational or funnel (see create).",
                    "enum": [
                      "single_step",
                      "multi_step",
                      "conversational",
                      "funnel"
                    ]
                  },
                  "qualifier_enabled": {
                    "type": "boolean",
                    "description": "Ask the qualifier_questions first."
                  },
                  "qualifier_questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Replaces the list (see create)."
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Replaces the list (see create)."
                  },
                  "qualification": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Merged (see create)."
                  },
                  "estimate": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Merged (see create)."
                  },
                  "calendar_routing": {
                    "type": "boolean",
                    "description": "Pick the calendar from the answers (see create)."
                  },
                  "fields": {
                    "type": "object",
                    "additionalProperties": true,
                    "description": "Merged, including address.service_area (see create)."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "fields": {
                  "address": {
                    "service_area": {
                      "enabled": true,
                      "mode": "radius",
                      "center": {
                        "lat": 32.7767,
                        "lng": -96.797,
                        "label": "Dallas, TX"
                      },
                      "radius_miles": 50
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-texting": {
      "get": {
        "operationId": "get_ai_texting",
        "tags": [
          "AI agent"
        ],
        "summary": "Read the AI texting agent and automatic text settings",
        "description": "AI replies, agent name, reply mode, goal, what it knows, booking link, first text, send window, hand-off, confirmation and reminder texts, missed-call text-back, email greeting, and a preview of its prompt. Says whether the sub-account has a phone number.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "set_ai_texting",
        "tags": [
          "AI agent"
        ],
        "summary": "Change the AI texting agent and automatic texts",
        "description": "Send only the settings to change, by these names: ai_replies, agent_name, reply_mode (auto | suggest), goal (book_appointment | collect_details | customer_support), business_context, booking_link, max_replies (1-15), reply_delay_minutes (1-120), ai_can_cancel, handoff_when_unsure, pause_ai_on_handoff, handoff_resume_days (0, 1, 2, 3, 7), greet_new_leads, first_message, smart_first_text (the AI writes each new lead's first text from their answers and the right calendar's open times; first_message becomes the backup), smart_first_text_goal (what that text should get them to do; empty = book an appointment), greet_delay_minutes, form_greet_delay_minutes, missed_call_text, missed_call_message, confirmation_text, confirmation_message, confirmation_email (the confirmation email with a calendar invite, plus the move and cancel emails), confirmation_email_language (en | es), reminder_24h, reminder_24h_message, reminder_1h, reminder_1h_message, reminder_5m (the 5-minute reminder, off by default), reminder_5m_message, email_greeting, email_greeting_subject, email_greeting_body, send_window (anytime | daily | booking_hours), send_window_start, send_window_end (\"HH:MM\"), ai_answers_email, prompt_addition (one more rule) or prompt (a full rewrite). Owners, agency admins and client admins can change these. Turning AI replies on lets it answer conversations still waiting for a reply.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "ai_replies": {
                    "type": "boolean",
                    "description": "The AI answers leads by text."
                  },
                  "agent_name": {
                    "type": "string",
                    "description": "First name the AI texts as (max 40)."
                  },
                  "reply_mode": {
                    "type": "string",
                    "description": "suggest = drafts each reply for a teammate to approve (GET /v1/reply-suggestions).",
                    "enum": [
                      "auto",
                      "suggest"
                    ]
                  },
                  "first_message": {
                    "type": "string",
                    "description": "First text to a new lead. Variables {first_name}, {agent}, {business}, {service}."
                  },
                  "send_window": {
                    "type": "string",
                    "description": "When automated texts may go out.",
                    "enum": [
                      "anytime",
                      "daily",
                      "booking_hours"
                    ]
                  },
                  "prompt_addition": {
                    "type": "string",
                    "description": "A rule added to the end of the AI's prompt (max 2000)."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "ai_replies": true,
                "agent_name": "Sarah",
                "reply_mode": "auto",
                "prompt_addition": "Always mention free estimates."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "ai_texting": {
                      "ai_replies": true,
                      "agent_name": "Sarah",
                      "reply_mode": "auto",
                      "send_window": "daily",
                      "send_window_start": "08:00",
                      "send_window_end": "21:00",
                      "prompt_characters": 2140
                    },
                    "changed": [
                      "ai_replies",
                      "agent_name",
                      "reply_mode",
                      "prompt_addition"
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/nurture-sequence": {
      "get": {
        "operationId": "get_nurture",
        "tags": [
          "AI agent"
        ],
        "summary": "Read the automatic follow-up sequence",
        "description": "Every text and email step with the day it goes out, whether each channel is on, and offers whose own follow-ups replace it for the leads they match.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "put": {
        "operationId": "set_nurture",
        "tags": [
          "AI agent"
        ],
        "summary": "Replace the follow-up texts (or emails)",
        "description": "Replaces one channel's steps and turns it on. Timing is the app's: the first 3 hours after the first text, then front-loaded days over span_days (about 5 days per message, at most 60), or the explicit days you send. At most 40 texts or 60 emails; email needs a verified sending domain. Pending sends that would change channel are cancelled.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "channel": {
                    "type": "string",
                    "description": "Default sms.",
                    "enum": [
                      "sms",
                      "email"
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "One message per step, in order."
                  },
                  "subjects": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Email only: one subject per message."
                  },
                  "span_days": {
                    "type": "number",
                    "description": "Days from the first message to the last (1-365)."
                  },
                  "days": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Instead of span_days: the day each message goes out, going up. 0 = 3 hours in."
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "Default true."
                  }
                },
                "required": [
                  "workspace_id",
                  "messages"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "channel": "sms",
                "messages": [
                  "Hi {first_name}, still looking for a quote?",
                  "Quick check-in from {business}: want me to hold a time for you?"
                ],
                "span_days": 7
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update_nurture",
        "tags": [
          "AI agent"
        ],
        "summary": "Switch follow-ups on or off, or reword one step",
        "description": "Send enabled, or step with message (and subject for email). A reworded step keeps its timing.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "channel": {
                    "type": "string",
                    "description": "Default sms.",
                    "enum": [
                      "sms",
                      "email"
                    ]
                  },
                  "enabled": {
                    "type": "boolean",
                    "description": "On or off."
                  },
                  "step": {
                    "type": "number",
                    "description": "Which step to reword (1 = first)."
                  },
                  "message": {
                    "type": "string",
                    "description": "The step's new wording."
                  },
                  "subject": {
                    "type": "string",
                    "description": "Email only: the new subject."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "channel": "sms",
                "step": 2,
                "message": "Hi {first_name}, any questions I can answer?"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "clear_nurture",
        "tags": [
          "AI agent"
        ],
        "summary": "Remove one channel's follow-up steps",
        "description": "Switches that channel off and cancels its pending sends.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "description": "Default sms.",
            "schema": {
              "type": "string",
              "enum": [
                "sms",
                "email"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/business-profile": {
      "get": {
        "operationId": "get_business_profile",
        "tags": [
          "Setup"
        ],
        "summary": "Read the business profile",
        "description": "Name, industry, time zone, address, country, business phone and business email (Settings → General).\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "set_business_profile",
        "tags": [
          "Setup"
        ],
        "summary": "Change the business profile",
        "description": "Send only what changes. A new time zone also moves the booking hours' time zone, as in the app.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "name": {
                    "type": "string",
                    "description": "Max 120."
                  },
                  "industry": {
                    "type": "string",
                    "description": "Max 80."
                  },
                  "timezone": {
                    "type": "string",
                    "description": "IANA zone, e.g. America/Chicago."
                  },
                  "address_line1": {
                    "type": "string",
                    "description": "Street."
                  },
                  "address_line2": {
                    "type": "string",
                    "description": "Suite, unit."
                  },
                  "city": {
                    "type": "string",
                    "description": "City."
                  },
                  "state": {
                    "type": "string",
                    "description": "State or region."
                  },
                  "postal_code": {
                    "type": "string",
                    "description": "ZIP or postal code."
                  },
                  "country": {
                    "type": "string",
                    "description": "Two-letter country code (US, CA, GB, AU; \"United States\" works too), or null. It picks the State list on leads, forms and booking pages, and the list a lead's state is matched against when the lead has no phone."
                  },
                  "business_phone": {
                    "type": "string",
                    "description": "US 10-digit or + and a country code."
                  },
                  "business_email": {
                    "type": "string",
                    "description": "Email address."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "timezone": "America/Chicago",
                "country": "US",
                "business_phone": "+14155550123"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/overview": {
      "get": {
        "operationId": "get_overview",
        "tags": [
          "Dashboard"
        ],
        "summary": "Dashboard numbers for a window",
        "description": "New leads, booked leads and appointments (each with the previous window of the same length for comparison), upcoming appointments, contacted, won and closed, speed to lead (median minutes to the first reply: anyone, AI or automation, a person), AI replies sent, calls (answered, missed, voicemails, AI calls, talk time), and stage_reach: of the leads created in the window, how many reached each pipeline stage (`total`, and `reached` keyed by stage key from GET /v1/stages; a lead counts for every stage it has been in, so a lead that sat and then won counts for both; the Overview's \"<Stage> rate\" cards divide reached by total). Moves made before 2026-10-16 are not known. stage_reach is null if it could not be read. Viewers limited to their own leads see only those.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "1-365, default 30.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "ISO start, instead of days (window at most 366 days).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "ISO end, default now.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "workspace_id": "uuid",
                    "window": {
                      "from": "2026-08-31T00:00:00Z",
                      "to": "2026-09-30T00:00:00Z",
                      "days": 30
                    },
                    "stats": {
                      "leads": 142,
                      "prev_leads": 120,
                      "booked_leads": 38,
                      "prev_booked_leads": 31,
                      "appointments": 41,
                      "upcoming_appointments": 12,
                      "contacted": 131,
                      "won": 9,
                      "closed": 15,
                      "new_unworked": 4,
                      "median_response_minutes": 0.8,
                      "median_response_minutes_auto": 0.4,
                      "median_response_minutes_human": 22.5,
                      "ai_replies": {
                        "total": 512,
                        "sms": 498,
                        "email": 9,
                        "other_channels": 5,
                        "leads": 96
                      },
                      "calls": {
                        "total": 88,
                        "inbound": 30,
                        "outbound": 58,
                        "answered": 61,
                        "missed_inbound": 6,
                        "voicemails": 9,
                        "ai_calls": 40,
                        "ai_receptionist_calls": 8,
                        "talk_seconds": 15540
                      },
                      "stage_reach": {
                        "total": 142,
                        "reached": {
                          "new": 142,
                          "contacted": 131,
                          "sat": 44,
                          "booked": 38,
                          "won": 9
                        }
                      }
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "get_usage",
        "tags": [
          "Dashboard"
        ],
        "summary": "Credits used by tool",
        "description": "What the sub-account spent in a window, by tool (the Usage tab's names: texts, lead alert texts, email, AI text replies, website chat widget, AI agents, phone calls, AI receptionist, AI calling, phone numbers, ad tools) and by day. unpaid counts events that ran while the account was out of credits.\n\nRequired scope: `billing:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "1-365, default 30.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "ISO start, instead of days.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "ISO end, default now.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "workspace_id": "uuid",
                    "window": {
                      "from": "2026-08-31T00:00:00Z",
                      "to": "2026-09-30T00:00:00Z",
                      "days": 30
                    },
                    "total_credits": 318.5,
                    "total_events": 2210,
                    "unpaid_events": 0,
                    "by_tool": [
                      {
                        "tool": "ai_text",
                        "label": "AI text replies",
                        "events": 512,
                        "credits": 128,
                        "unpaid": 0
                      },
                      {
                        "tool": "messaging",
                        "label": "Texts",
                        "events": 1404,
                        "credits": 105.3,
                        "unpaid": 0
                      }
                    ],
                    "by_day": [
                      {
                        "date": "2026-09-29",
                        "events": 81,
                        "credits": 11.5
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations": {
      "get": {
        "operationId": "list_conversations",
        "tags": [
          "Inbox"
        ],
        "summary": "The Inbox: conversations, newest first",
        "description": "Every lead with a message either way (or an unread one), like the Inbox: unread count, archive state, whether the AI is paused on it (and the question it handed to the team), and the last message or call. The first page also returns the Inbox counts. Read the thread with GET /v1/leads/{lead_id}/conversation.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "archived",
            "in": "query",
            "required": false,
            "description": "true = the Archived tab. Default false.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "unread",
            "in": "query",
            "required": false,
            "description": "Only unread conversations.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "assigned_to",
            "in": "query",
            "required": false,
            "description": "A user id, \"me\" or \"unassigned\".",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Name, email or phone contains (2-80 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "imessage_line_id",
            "in": "query",
            "required": false,
            "description": "Only the conversations this iMessage Mac has had (GET /v1/imessage/lines), like the Inbox's number filter.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "conversations": [
                      {
                        "lead_id": "uuid",
                        "workspace_id": "uuid",
                        "name": "Jane Doe",
                        "phone": "+14155550123",
                        "email": null,
                        "status": "contacted",
                        "stage_key": "contacted",
                        "assigned_to": null,
                        "unread": true,
                        "unread_count": 2,
                        "archived": false,
                        "ai": {
                          "paused": false,
                          "paused_until": null,
                          "pause_reason": null,
                          "handoff_question": null
                        },
                        "channel": "sms",
                        "last_message": {
                          "id": "uuid",
                          "channel": "sms",
                          "direction": "inbound",
                          "body": "Can you come Thursday?",
                          "subject": null,
                          "sent_by": null,
                          "created_at": "2026-09-30T15:02:00Z"
                        },
                        "last_inbound_at": "2026-09-30T15:02:00Z",
                        "last_outbound_at": "2026-09-30T14:40:00Z",
                        "last_activity_at": "2026-09-30T15:02:00Z"
                      }
                    ],
                    "has_more": true,
                    "next_cursor": "MjAyNi0wOS0zMFQxNTowMjowMCswMDowMHx1dWlk",
                    "counts": {
                      "open": 210,
                      "unread": 7,
                      "archived": 54
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations/{lead_id}/read": {
      "post": {
        "operationId": "mark_conversation_read",
        "tags": [
          "Inbox"
        ],
        "summary": "Mark a conversation read",
        "description": "Anyone who can see the lead can, as in the Inbox.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations/{lead_id}/unread": {
      "post": {
        "operationId": "mark_conversation_unread",
        "tags": [
          "Inbox"
        ],
        "summary": "Mark a conversation unread",
        "description": "Required scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations/{lead_id}/archive": {
      "post": {
        "operationId": "archive_conversation",
        "tags": [
          "Inbox"
        ],
        "summary": "Archive a conversation",
        "description": "As in the app, archiving switches the lead's automatic follow-up texts off. A new message from the lead brings the conversation back.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/conversations/{lead_id}/unarchive": {
      "post": {
        "operationId": "unarchive_conversation",
        "tags": [
          "Inbox"
        ],
        "summary": "Move a conversation back to the Inbox",
        "description": "Follow-ups switched off by archiving stay off.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/ai-pause": {
      "post": {
        "operationId": "set_lead_ai_pause",
        "tags": [
          "Inbox"
        ],
        "summary": "Pause or resume the AI on one lead",
        "description": "paused: true stops AI replies to this lead (and its automatic follow-ups at send time) until someone turns it back on, or until `until`. paused: false turns it back on and clears any hand-off. The sub-account-wide switch is ai_replies on PATCH /v1/ai-texting.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "paused": {
                    "type": "boolean",
                    "description": "Pause (true) or resume (false)."
                  },
                  "until": {
                    "type": "string",
                    "description": "ISO time the AI turns itself back on (paused: true only, at most a year away)."
                  }
                },
                "required": [
                  "paused"
                ],
                "additionalProperties": true
              },
              "example": {
                "paused": true,
                "until": "2026-10-07T15:00:00Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead_id": "uuid",
                    "ai": {
                      "paused": true,
                      "paused_until": "2026-10-07T15:00:00.000Z",
                      "pause_reason": "Paused from the API",
                      "handoff_question": null
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/reply-suggestions": {
      "get": {
        "operationId": "list_reply_suggestions",
        "tags": [
          "Inbox"
        ],
        "summary": "AI suggested replies waiting for a teammate",
        "description": "When AI texting's reply_mode is suggest, the AI drafts its reply to each text or email here instead of sending it. Each one shows the lead, the draft, and the appointment it would book or cancel. reply_mode in the response says whether the sub-account is in suggest mode.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Default pending.",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "sending",
                "sent",
                "dismissed",
                "superseded",
                "failed",
                "all"
              ]
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "One lead's suggestions.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "reply_mode": "suggest",
                    "suggestions": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "lead_id": "uuid",
                        "channel": "sms",
                        "body": "Thursday at 2pm works! I've put you down, see you then.",
                        "status": "pending",
                        "error": null,
                        "inbound_at": "2026-09-30T15:02:00Z",
                        "sent_body": null,
                        "decided_at": null,
                        "created_at": "2026-09-30T15:02:20Z",
                        "updated_at": "2026-09-30T15:02:20Z",
                        "books": {
                          "starts_at": "2026-10-02T19:00:00Z",
                          "ends_at": "2026-10-02T20:00:00Z",
                          "title": "Roof inspection",
                          "timezone": "America/New_York",
                          "location": null,
                          "is_arrival_window": false
                        },
                        "cancels": null,
                        "lead": {
                          "id": "uuid",
                          "full_name": "Jane Doe",
                          "phone": "+14155550123",
                          "email": null
                        }
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/reply-suggestions/{suggestion_id}/dismiss": {
      "post": {
        "operationId": "dismiss_reply_suggestion",
        "tags": [
          "Inbox"
        ],
        "summary": "Dismiss a suggested reply",
        "description": "Nothing is sent. The AI does not suggest again until the lead writes. 409 when it was already handled.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "suggestion_id",
            "in": "path",
            "required": true,
            "description": "Suggestion id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/reply-suggestions/{suggestion_id}/approve": {
      "post": {
        "operationId": "approve_reply_suggestion",
        "tags": [
          "Inbox"
        ],
        "summary": "Send a suggested reply",
        "description": "Sends it to the lead as the AI (edited, if you send body), makes the booking or cancellation it decided on, and is charged exactly like an automatic AI reply plus the text, through the same code as the Inbox's Send button. Owners and admins only. 409 = someone already answered or the lead wrote again (nothing sent), 422 = not sent for a reason in `error` (e.g. AI paused, out of credits, that time is no longer open), 503 = a sending hiccup, try again.\n\nRequired scope: `messaging:write`.\n\nSpends credits.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "suggestion_id",
            "in": "path",
            "required": true,
            "description": "Suggestion id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "description": "The edited reply to send instead (texts up to 1600 characters, emails 5000)."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "body": "Thursday at 2pm works! See you then."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "suggestion_id": "uuid",
                    "sent": true,
                    "status": "sent",
                    "booked": true,
                    "cancelled": false
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/ConfirmationRequired"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calls": {
      "get": {
        "operationId": "list_calls",
        "tags": [
          "Calls"
        ],
        "summary": "Phone calls, newest first",
        "description": "Every call on the sub-account's numbers: direction, type (softphone, bridge, inbound, forward, ai, ai_receptionist), status, duration, voicemail, the AI's outcome and summary, and the lead. Get one for its transcript and recording.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "direction",
            "in": "query",
            "required": false,
            "description": "Inbound or outbound.",
            "schema": {
              "type": "string",
              "enum": [
                "inbound",
                "outbound"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Call type.",
            "schema": {
              "type": "string",
              "enum": [
                "softphone",
                "bridge",
                "inbound",
                "forward",
                "ai",
                "ai_receptionist"
              ]
            }
          },
          {
            "name": "outcome",
            "in": "query",
            "required": false,
            "description": "The Calls tab's outcome filter.",
            "schema": {
              "type": "string",
              "enum": [
                "connected",
                "missed",
                "voicemail"
              ]
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "One lead's calls.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO time, calls at or after.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "ISO time, calls before.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "calls": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "lead_id": "uuid",
                        "direction": "inbound",
                        "mode": "ai_receptionist",
                        "status": "completed",
                        "from_number": "+14155550123",
                        "to_number": "+14155550199",
                        "answered_at": "2026-09-30T15:00:04Z",
                        "ended_at": "2026-09-30T15:03:10Z",
                        "duration_sec": 186,
                        "is_voicemail": false,
                        "voicemail_read_at": null,
                        "ai_outcome": "booked",
                        "ai_summary": "Caller wanted a roof inspection; booked Thursday 2pm.",
                        "ai_booking_id": "uuid",
                        "campaign_id": null,
                        "created_at": "2026-09-30T15:00:00Z",
                        "ai_call": true,
                        "has_recording": true,
                        "lead": {
                          "id": "uuid",
                          "full_name": "Jane Doe",
                          "phone": "+14155550123"
                        }
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/calls/{call_id}": {
      "get": {
        "operationId": "get_call",
        "tags": [
          "Calls"
        ],
        "summary": "One call: summary, transcript and recording",
        "description": "recording.url is a fresh link that works for 15 minutes; ask again for a new one.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "description": "Call id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "call": {
                      "id": "uuid",
                      "direction": "inbound",
                      "mode": "ai_receptionist",
                      "status": "completed",
                      "duration_sec": 186,
                      "ai_outcome": "booked",
                      "ai_summary": "Caller wanted a roof inspection; booked Thursday 2pm.",
                      "transcript": "AI: Thanks for calling...\nCaller: Hi, I need...",
                      "recording": {
                        "url": "https://.../lead-media/...mp3?token=...",
                        "expires_at": "2026-09-30T15:20:00Z",
                        "expires_in_seconds": 900
                      },
                      "lead": {
                        "id": "uuid",
                        "full_name": "Jane Doe",
                        "phone": "+14155550123"
                      }
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/call-campaigns": {
      "get": {
        "operationId": "list_call_campaigns",
        "tags": [
          "Calls"
        ],
        "summary": "AI calling campaigns and their progress",
        "description": "Leads, calls placed and connected, bookings, and credits used against the spend cap. Owners and admins only.\n\nRequired scope: `messaging:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Only this status.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "running",
                "paused",
                "completed"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/call-campaigns/{campaign_id}/pause": {
      "post": {
        "operationId": "pause_call_campaign",
        "tags": [
          "Calls"
        ],
        "summary": "Pause a running AI calling campaign",
        "description": "Its queued calls are cancelled. Resuming places paid calls, so it is done in the app. 409 when it is not running.\n\nRequired scope: `messaging:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "campaign_id",
            "in": "path",
            "required": true,
            "description": "Campaign id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-lessons": {
      "get": {
        "operationId": "list_ai_lessons",
        "tags": [
          "AI Brain"
        ],
        "summary": "What the team has taught the AI",
        "description": "Settings → AI Brain: rules (instructions every AI reply follows), good examples (thumbs up) and lessons (thumbs down: what was wrong, a better reply, never send anything like it again). The AI texter and the voice agent read the active ones on every reply. Owners and admins only.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "description": "Only this kind.",
            "schema": {
              "type": "string",
              "enum": [
                "good",
                "avoid",
                "rule"
              ]
            }
          },
          {
            "name": "active",
            "in": "query",
            "required": false,
            "description": "Only switched on (true) or off (false).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 50.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lessons": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "kind": "rule",
                        "channel": "sms",
                        "ai_message": null,
                        "lead_message": null,
                        "better_reply": null,
                        "reasons": [],
                        "note": "Never quote prices by text.",
                        "never_again": false,
                        "source": "brain",
                        "lead_id": null,
                        "active": true,
                        "created_at": "2026-09-30T12:00:00Z",
                        "updated_at": "2026-09-30T12:00:00Z",
                        "message_id": null
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_ai_lesson",
        "tags": [
          "AI Brain"
        ],
        "summary": "Add a rule the AI follows",
        "description": "Like Add rule in Settings → AI Brain. channel limits it to texts (sms), email or calls (voice); leave it out for everywhere. To teach from a specific reply, rate it (POST /v1/messages/{message_id}/rating). Owners and admins only; at most 200 rules.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "note": {
                    "type": "string",
                    "description": "The rule, max 600 characters."
                  },
                  "channel": {
                    "type": "string",
                    "description": "Where it applies. Default everywhere.",
                    "enum": [
                      "sms",
                      "email",
                      "voice",
                      "all"
                    ]
                  },
                  "active": {
                    "type": "boolean",
                    "description": "Default true."
                  }
                },
                "required": [
                  "workspace_id",
                  "note"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "note": "Never quote prices by text; offer a free estimate visit instead.",
                "channel": "sms"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ai-lessons/{lesson_id}": {
      "patch": {
        "operationId": "update_ai_lesson",
        "tags": [
          "AI Brain"
        ],
        "summary": "Switch a lesson off or reword it",
        "description": "What can change depends on the kind, as in the app: a rule's note, channel and active; a thumbs-down lesson's note, better_reply, never_again and active; a good example's active only.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lesson_id",
            "in": "path",
            "required": true,
            "description": "Lesson id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "active": {
                    "type": "boolean",
                    "description": "On or off."
                  },
                  "note": {
                    "type": "string",
                    "description": "Max 600."
                  },
                  "channel": {
                    "type": "string",
                    "description": "Rules only.",
                    "enum": [
                      "sms",
                      "email",
                      "voice",
                      "all"
                    ]
                  },
                  "better_reply": {
                    "type": "string",
                    "description": "Thumbs-down lessons only, max 2000."
                  },
                  "never_again": {
                    "type": "boolean",
                    "description": "Thumbs-down lessons only."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "active": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_ai_lesson",
        "tags": [
          "AI Brain"
        ],
        "summary": "Delete a lesson for good",
        "description": "active: false on PATCH keeps it but switches it off.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lesson_id",
            "in": "path",
            "required": true,
            "description": "Lesson id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/messages/{message_id}/rating": {
      "post": {
        "operationId": "rate_ai_message",
        "tags": [
          "AI Brain"
        ],
        "summary": "Thumbs up or down on an AI message",
        "description": "Exactly the Inbox's rating. up keeps the reply as a good example; down records what was wrong (reasons), what it should have said (better_reply), a note, and by default never to send anything close again; clear removes the rating. Rating the same message again replaces its lesson. Works on messages and calls sent to the lead (message ids from GET /v1/leads/{lead_id}/conversation). Owners and admins only.\n\nRequired scope: `workspaces:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "message_id",
            "in": "path",
            "required": true,
            "description": "The message (lead event) id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "rating": {
                    "type": "string",
                    "description": "up, down or clear.",
                    "enum": [
                      "up",
                      "down",
                      "clear"
                    ]
                  },
                  "reasons": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "down only: wrong_info, too_pushy, too_long, missed_question, wrong_tone, should_not_reply."
                  },
                  "better_reply": {
                    "type": "string",
                    "description": "down only: what it should have said (max 2000)."
                  },
                  "note": {
                    "type": "string",
                    "description": "down only: a note (max 600)."
                  },
                  "never_again": {
                    "type": "boolean",
                    "description": "down only. Default true."
                  }
                },
                "required": [
                  "rating"
                ],
                "additionalProperties": true
              },
              "example": {
                "rating": "down",
                "reasons": [
                  "too_pushy"
                ],
                "better_reply": "No rush at all, happy to answer any questions first."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "message_id": "uuid",
                    "rating": "down",
                    "lesson_id": "uuid",
                    "lesson": {
                      "id": "uuid",
                      "kind": "avoid",
                      "channel": "sms",
                      "ai_message": "Book now before slots fill up!",
                      "better_reply": "No rush at all, happy to answer any questions first.",
                      "reasons": [
                        "too_pushy"
                      ],
                      "never_again": true,
                      "active": true
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/phone-numbers": {
      "get": {
        "operationId": "list_phone_numbers",
        "tags": [
          "Setup"
        ],
        "summary": "The sub-account's phone numbers",
        "description": "Number, name, default, capabilities, texting registration and caller-name status, and who may use it: assigned_user_id (a number that belongs to one team member: it rings only them and other technicians can't text from it), tech_can_answer and tech_can_use (whether it rings technicians and whether they may call and text from it). Buying and releasing numbers is done in the app. iMessage Macs: GET /v1/imessage/lines.\n\nRequired scope: `phone_numbers:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_released",
            "in": "query",
            "required": false,
            "description": "Include released numbers.",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "phone_numbers": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "phone_number": "+14155550199",
                        "friendly_name": "Main line",
                        "is_default": true,
                        "capabilities": {
                          "sms": true,
                          "voice": true,
                          "mms": true
                        },
                        "sms_registration_status": "ready",
                        "cnam_display_name": "ACME ROOFING",
                        "cnam_status": "approved",
                        "shaken_status": null,
                        "voice_forward_enabled": false,
                        "created_at": "2026-09-01T00:00:00Z",
                        "released_at": null,
                        "texting_ready": true
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/invoices": {
      "get": {
        "operationId": "list_invoices",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Invoices (read only)",
        "description": "The sub-account's invoices, newest first. effective_status adds overdue (sent and past due), as the app shows it. kind is invoice, deposit (it lists the whole job but asks only for deposit_cents now; deposit_percent when it was a percent) or balance (made by Bill the balance: deposit_invoice_id is the deposit it follows and deposit_applied_cents comes off the job total). total_cents is always what this invoice asks for. Owners and admins only. Payment processor details are never returned.\n\nRequired scope: `billing:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "sent",
                "paid",
                "void",
                "overdue"
              ]
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "One lead's invoices.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "invoices": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "lead_id": "uuid",
                        "number": "INV-000042",
                        "status": "sent",
                        "currency": "usd",
                        "issue_date": "2026-09-20",
                        "due_date": "2026-09-27",
                        "customer_name": "Jane Doe",
                        "customer_email": "jane@example.com",
                        "customer_phone": "+14155550123",
                        "total_cents": 125000,
                        "amount_paid_cents": 0,
                        "collect_payment": true,
                        "payment_gateway": "stripe",
                        "sent_at": "2026-09-20T15:00:00Z",
                        "viewed_at": null,
                        "paid_at": null,
                        "created_at": "2026-09-20T14:55:00Z",
                        "updated_at": "2026-09-20T15:00:00Z",
                        "effective_status": "overdue",
                        "balance_cents": 125000
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/invoices/{invoice_id}": {
      "get": {
        "operationId": "get_invoice",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "One invoice with its line items and history",
        "description": "Adds the customer's address, notes, terms, subtotal, discount and tax, the PDF link, line items, the event history (created, sent, viewed, paid) and public_path, the customer's view-and-pay page on the sub-account's domain (none for drafts).\n\nRequired scope: `billing:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "required": true,
            "description": "Invoice id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/estimates": {
      "get": {
        "operationId": "list_estimates",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Estimates (read only)",
        "description": "The sub-account's estimates, newest first, as the Estimates tab lists them: number, title, the customer, status and effective_status (expired: sent and past its last day), when it was sent, viewed, approved (and by whom) or declined (and why), the invoice it became, its Good / Better / Best options with their totals, and total_cents (the option the customer picked, else the recommended one). Technicians and Staff limited to their own leads see the estimates for leads they can see and ones they made without a lead, as in the app.\n\nRequired scope: `billing:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "sent",
                "approved",
                "declined",
                "expired",
                "converted"
              ]
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "One lead's estimates.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "estimates": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "lead_id": "uuid",
                        "number": "EST-001042",
                        "title": "Duct cleaning, whole house",
                        "status": "sent",
                        "currency": "usd",
                        "issue_date": "2026-10-20",
                        "expires_at": "2026-11-19",
                        "customer_name": "Jane Doe",
                        "customer_email": "jane@example.com",
                        "customer_phone": "+14155550123",
                        "selected_option_id": null,
                        "sent_at": "2026-10-20T16:00:00Z",
                        "viewed_at": "2026-10-20T18:12:00Z",
                        "approved_at": null,
                        "approved_by_name": null,
                        "declined_at": null,
                        "decline_reason": null,
                        "converted_invoice_id": null,
                        "created_by": "uuid",
                        "created_at": "2026-10-20T15:40:00Z",
                        "updated_at": "2026-10-20T18:12:00Z",
                        "effective_status": "sent",
                        "total_cents": 64900,
                        "options": [
                          {
                            "id": "uuid",
                            "name": "Good",
                            "is_recommended": false,
                            "total_cents": 39900
                          },
                          {
                            "id": "uuid",
                            "name": "Better",
                            "is_recommended": true,
                            "total_cents": 64900
                          }
                        ]
                      }
                    ],
                    "has_more": false,
                    "next_cursor": null
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "post": {
        "operationId": "create_estimate",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Create an estimate (draft)",
        "description": "Saved as a draft exactly as the estimate editor saves one: the sub-account's next number, its default terms, days valid and tax rate, the lead's name, email, phone and address filled in. Send items for one option, or options (2-4, e.g. Good / Better / Best) each with its items; every option's subtotal, tax and total are worked out as the editor does (each line rounded, tax on taxable lines). Answers with the estimate as GET /v1/estimates/{estimate_id} shows it. Send it with POST /v1/estimates/{estimate_id}/send. Technicians only while the sub-account lets them make estimates, and only for their own leads.\n\nRequired scope: `billing:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workspace_id": {
                    "type": "string",
                    "description": "Sub-account id (omit on keys restricted to one sub-account)."
                  },
                  "lead_id": {
                    "type": "string",
                    "description": "Who it is for (fills in the customer; needed to send it). Or customer_name."
                  },
                  "title": {
                    "type": "string",
                    "description": "Max 200, e.g. Whole-house duct cleaning."
                  },
                  "intro": {
                    "type": "string",
                    "description": "A note to the customer at the top (max 2000)."
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "One option's lines: [{ description (the line's name, max 300), details? (max 2000), image_url? (https), quantity? (default 1), unit_price_cents, taxable? (default true) }]."
                  },
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Instead of items, up to 4 choices: [{ name, description?, image_url?, recommended?, items: [...] }]. One is recommended (the first marked, else the first)."
                  },
                  "tax_rate": {
                    "type": "number",
                    "description": "Percent, 0-30. Default: the sub-account's."
                  },
                  "valid_days": {
                    "type": "number",
                    "description": "Days it is valid (1-365). Default: the sub-account's. Or expires_at."
                  },
                  "expires_at": {
                    "type": "string",
                    "description": "Last day, YYYY-MM-DD, or null for no end."
                  },
                  "terms": {
                    "type": "string",
                    "description": "Max 4000. Default: the sub-account's estimate terms."
                  },
                  "currency": {
                    "type": "string",
                    "description": "3 letters, default usd."
                  },
                  "customer_name": {
                    "type": "string",
                    "description": "Without a lead, or to change what the lead fills in."
                  },
                  "customer_email": {
                    "type": "string",
                    "description": "Customer email."
                  },
                  "customer_phone": {
                    "type": "string",
                    "description": "Customer phone."
                  },
                  "customer_address": {
                    "type": "string",
                    "description": "Customer address."
                  }
                },
                "required": [
                  "workspace_id"
                ],
                "additionalProperties": true
              },
              "example": {
                "workspace_id": "uuid",
                "lead_id": "uuid",
                "title": "Duct cleaning",
                "options": [
                  {
                    "name": "Good",
                    "items": [
                      {
                        "description": "Main trunk lines",
                        "unit_price_cents": 29900
                      }
                    ]
                  },
                  {
                    "name": "Better",
                    "recommended": true,
                    "items": [
                      {
                        "description": "Every vent and return",
                        "details": "Up to 20 vents, before and after photos.",
                        "unit_price_cents": 49900
                      }
                    ]
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/estimates/{estimate_id}": {
      "get": {
        "operationId": "get_estimate",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "One estimate with its options, lines and history",
        "description": "Adds the customer's address, intro, terms, tax rate and the customer's approval note, every option (name, description, photo, recommended, subtotal, tax and total) with its lines (name, details, photo, quantity, unit price, taxable), the history (created, sent, viewed, approved, declined) and public_path, the customer's page on the sub-account's domain (none for drafts).\n\nRequired scope: `billing:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "description": "Estimate id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "patch": {
        "operationId": "update_estimate",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Change an estimate",
        "description": "Send only what changes. options (or items) replace every option and line, as the editor saves; a new tax_rate re-totals the options. An approved estimate or one already made into an invoice answers 409: make a new one.\n\nRequired scope: `billing:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "description": "Estimate id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "title": {
                    "type": "string",
                    "description": "New title."
                  },
                  "intro": {
                    "type": "string",
                    "description": "New note at the top."
                  },
                  "lead_id": {
                    "type": "string",
                    "description": "Or null."
                  },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Replaces the options with one."
                  },
                  "options": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Replaces the options."
                  },
                  "tax_rate": {
                    "type": "number",
                    "description": "Percent, 0-30; re-totals the options."
                  },
                  "valid_days": {
                    "type": "number",
                    "description": "Days valid from today (1-365)."
                  },
                  "expires_at": {
                    "type": "string",
                    "description": "Last day, YYYY-MM-DD, or null."
                  },
                  "terms": {
                    "type": "string",
                    "description": "New terms."
                  },
                  "customer_name": {
                    "type": "string",
                    "description": "Customer name."
                  },
                  "customer_email": {
                    "type": "string",
                    "description": "Customer email."
                  },
                  "customer_phone": {
                    "type": "string",
                    "description": "Customer phone."
                  },
                  "customer_address": {
                    "type": "string",
                    "description": "Customer address."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "tax_rate": 8.25
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_estimate",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Delete an estimate",
        "description": "One that became an invoice stays (409), so the invoice still points at it.\n\nRequired scope: `billing:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "description": "Estimate id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/price-book": {
      "get": {
        "operationId": "list_price_book",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "The price book",
        "description": "The saved items estimates and invoices pick their lines from: name, details, category, unit price, taxable, photo, and how often it's used (most used first).\n\nRequired scope: `billing:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Name or category contains (2-80 characters).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "include_inactive",
            "in": "query",
            "required": false,
            "description": "Include archived items.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-500, default 100.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "items": [
                      {
                        "id": "uuid",
                        "workspace_id": "uuid",
                        "name": "Dryer vent cleaning",
                        "description": "Brush and vacuum the full run, check the exterior flap.",
                        "category": "Vents",
                        "unit_price_cents": 14900,
                        "taxable": true,
                        "image_url": null,
                        "is_active": true,
                        "usage_count": 37,
                        "last_used_at": "2026-10-22T14:00:00Z",
                        "created_at": "2026-09-01T00:00:00Z",
                        "updated_at": "2026-10-22T14:00:00Z"
                      }
                    ]
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/estimates/{estimate_id}/send": {
      "post": {
        "operationId": "send_estimate",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Send an estimate to the lead",
        "description": "Like the editor's Send: a text and/or an email to the estimate's lead with the link to review and approve it (on the sub-account's own domain when it has one), in the editor's own words unless you send message (it must include {link}). Sent as the key's person, with the usual opt-out, credit and limit checks; each is billed like any text or email. A draft (or a declined or expired one) becomes sent. sent lists each channel and why one didn't go.\n\nRequired scope: `billing:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "description": "Estimate id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "channel": {
                    "type": "string",
                    "description": "Default both (whichever the lead has).",
                    "enum": [
                      "sms",
                      "email",
                      "both"
                    ]
                  },
                  "message": {
                    "type": "string",
                    "description": "Your own wording, with {link}."
                  },
                  "subject": {
                    "type": "string",
                    "description": "The email's subject."
                  }
                },
                "additionalProperties": true
              },
              "example": {
                "channel": "sms"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "sent": [
                      {
                        "channel": "sms",
                        "ok": true
                      }
                    ],
                    "link": "https://book.acme.com/e/abc123",
                    "status": "sent"
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/estimates/{estimate_id}/convert": {
      "post": {
        "operationId": "convert_estimate",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Make the invoice",
        "description": "Convert to invoice: a draft invoice from the option the customer picked (else the recommended one, or option_id), with its lines, the estimate's tax rate and the sub-account's due days, terms and notes; the estimate becomes converted. Owners and admins (invoices are theirs). Send the invoice from the app.\n\nRequired scope: `billing:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "estimate_id",
            "in": "path",
            "required": true,
            "description": "Estimate id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "option_id": {
                    "type": "string",
                    "description": "The option to invoice."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "estimate_id": "uuid",
                    "status": "converted",
                    "invoice": {
                      "id": "uuid",
                      "number": "INV-000124",
                      "status": "draft",
                      "total_cents": 49900
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/sales": {
      "get": {
        "operationId": "get_sales",
        "tags": [
          "Dashboard"
        ],
        "summary": "The Sales page: won jobs, parts, tips and profit",
        "description": "Settings > Features > Sales (off until an owner or admin turns it on: 403 feature_off until then). Won jobs in the window by the date they were won, as the Sales page adds them up: what customers paid, parts, tips and profit in total, per technician (deal_sold_by, else whoever the lead is assigned to), per lead source and per tag, plus the jobs themselves. Every group also has plans, monthly_cents (the monthly revenue its new plans add) and expected_cents (what its jobs are expected to bring in, one-time jobs at their amount), and each job its deal_type and plan (Plans & memberships). Record a sale with PATCH /v1/leads/{lead_id}: status won, deal_value_cents, deal_parts_cents, deal_tip_cents, deal_sold_by. Owners and admins only.\n\nRequired scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "1-365, default 30.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "ISO start, instead of days.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "ISO end, default now.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/ad-insights": {
      "get": {
        "operationId": "get_ad_insights",
        "tags": [
          "Ads & Google"
        ],
        "summary": "The sub-account's Ad Insights",
        "description": "Exactly what its Ad Insights page shows: spend, leads, cost per lead, impressions and clicks for the Meta ad accounts attached to it (one, or all of them added up with each account's share in accounts, and an error for one that couldn't be read), each read with whichever connected Facebook profile can; per campaign and per ad, only the campaigns and ads the agency picked for this sub-account; ads left out (ads_hidden) when the agency hides them from the client. Amounts are added up in each account's own currency (accounts_meta). 403 ad_insights_off when Ad Insights is off for it.\n\nRequired scope: `meta:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ad_account_id",
            "in": "query",
            "required": false,
            "description": "\"all\" (default) or one attached account, act_123.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "date_preset",
            "in": "query",
            "required": false,
            "description": "Default last_30d.",
            "schema": {
              "type": "string",
              "enum": [
                "today",
                "yesterday",
                "last_7d",
                "last_14d",
                "last_30d",
                "last_90d",
                "this_month",
                "last_month",
                "maximum"
              ]
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD, with until (instead of date_preset).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "until",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "Only this campaign's ads.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "workspace_id": "uuid",
                    "summary": {
                      "total_spend": 1240.5,
                      "total_leads": 62,
                      "avg_cost_per_lead": 20.01,
                      "total_impressions": 88120,
                      "total_clicks": 1904
                    },
                    "campaigns": [
                      {
                        "id": "120210000000",
                        "name": "Roof leads - Dallas",
                        "effective_status": "ACTIVE",
                        "spend": 820.1,
                        "leads": 44,
                        "impressions": 60110,
                        "clicks": 1302
                      }
                    ],
                    "ads": [],
                    "account_id": "all",
                    "account_ids": [
                      "act_123",
                      "act_456"
                    ],
                    "accounts_meta": {
                      "act_123": {
                        "name": "Acme Roofing",
                        "currency": "USD"
                      }
                    },
                    "accounts": [
                      {
                        "id": "act_123",
                        "total_spend": 820.1,
                        "total_leads": 44,
                        "campaigns": 3,
                        "running": 2,
                        "daily_budget": 40
                      }
                    ],
                    "window": {
                      "date_preset": "last_30d"
                    },
                    "filtered": true,
                    "ads_hidden": false
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/google-ads": {
      "get": {
        "operationId": "google_ads_status",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Google Ads: the connection and conversions sent",
        "description": "The sub-account's own Google Ads connection (Ad Insights > Google Ads): its ad accounts (customers), the one in use, whether booked / won leads are sent back as conversions and to which conversion actions, and the newest conversions with their status (pending, sent, failed, skipped) and how each lead was matched (gclid, gbraid, wbraid or email / phone). Owners and admins.\n\nRequired scope: `meta:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/google-ads/report": {
      "get": {
        "operationId": "google_ads_report",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Google Ads reports, live",
        "description": "One of the Google Ads screens, read live from Google for one of the sub-account's ad accounts: overview (campaigns with spend, clicks, conversions, totals and by day), ad_groups, keywords, ads, search_terms, negatives, campaign_settings (campaign_id), conversion_actions, bidding, recommendations. Nothing is changed. Owners and admins.\n\nRequired scope: `meta:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "report",
            "in": "query",
            "required": false,
            "description": "Default overview.",
            "schema": {
              "type": "string",
              "enum": [
                "overview",
                "ad_groups",
                "keywords",
                "ads",
                "search_terms",
                "negatives",
                "campaign_settings",
                "conversion_actions",
                "bidding",
                "recommendations"
              ]
            }
          },
          {
            "name": "range",
            "in": "query",
            "required": false,
            "description": "Default last_30d.",
            "schema": {
              "type": "string",
              "enum": [
                "today",
                "last_7d",
                "last_14d",
                "last_30d",
                "last_90d"
              ]
            }
          },
          {
            "name": "customer_id",
            "in": "query",
            "required": false,
            "description": "One of its accounts (GET /v1/google-ads). Default: the one picked in the app.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "campaign_id",
            "in": "query",
            "required": false,
            "description": "Narrow to one campaign.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ad_group_id",
            "in": "query",
            "required": false,
            "description": "Narrow to one ad group.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "search_terms: rows, default 500.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/google-business/profiles": {
      "get": {
        "operationId": "list_gbp_profiles",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Google Business Profiles",
        "description": "Every Business Profile connected to the sub-account (it can have several): the location, rating, review count, whether Google's API answers for it, and its auto-reply, auto-post and photo settings; plus the Google logins connected (email only). Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/google-business/reviews": {
      "get": {
        "operationId": "list_gbp_reviews",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Google reviews and replies",
        "description": "Reviews synced from Google every 15 minutes, newest first, with the reply sent, the draft waiting for approval and its status. Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "profile_id",
            "in": "query",
            "required": false,
            "description": "One profile.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter.",
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "draft",
                "sending",
                "sent",
                "skipped",
                "failed"
              ]
            }
          },
          {
            "name": "unanswered",
            "in": "query",
            "required": false,
            "description": "Only reviews without a reply.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "max_stars",
            "in": "query",
            "required": false,
            "description": "This many stars or fewer.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/google-business/posts": {
      "get": {
        "operationId": "list_gbp_posts",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Google Business Profile posts",
        "description": "Drafts, scheduled and published posts (title, text, button, offer, photo, when, the live link). Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "profile_id",
            "in": "query",
            "required": false,
            "description": "One profile.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter.",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "scheduled",
                "publishing",
                "published",
                "failed"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/google-business/optimizer": {
      "get": {
        "operationId": "list_gbp_optimizer",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Profile Optimizer runs",
        "description": "Each Profile Optimizer check, newest first: the score, what it found, the keywords, its suggestions and the changes made from it (and undone). Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "profile_id",
            "in": "query",
            "required": false,
            "description": "One profile.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-25, default 5.",
            "schema": {
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/map-rankings": {
      "get": {
        "operationId": "list_map_rankings",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Map Rankings: keywords and scans",
        "description": "Where the business ranks on Google Maps across a grid around it: the keywords tracked (grid, schedule, next and last scan) and the scans, newest first, each with its summary (points, found, top 3, average rank). Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "keyword_id",
            "in": "query",
            "required": false,
            "description": "One keyword's scans.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "profile_id",
            "in": "query",
            "required": false,
            "description": "One profile.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/map-rankings/scans/{scan_id}": {
      "get": {
        "operationId": "get_rank_scan",
        "tags": [
          "Ads & Google"
        ],
        "summary": "One Map Rankings scan",
        "description": "Every grid point with its rank (null: not in the top 20), the competitors found, and the next steps to rank #1 once they've been written (they are written when the scan is first opened in the app). Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "scan_id",
            "in": "path",
            "required": true,
            "description": "Scan id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/listings": {
      "get": {
        "operationId": "get_listings",
        "tags": [
          "Ads & Google"
        ],
        "summary": "Business Listings",
        "description": "The directories the business is being listed on: each one's status (queued, scanning, listed, mismatch, not_listed, working, needs_you, submitted, live, owner, skipped, failed) with counts, what differs or what's needed from the owner, the listing link, and the latest activity. Passwords and verification codes are never returned. Owners and admins.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/support/tickets": {
      "get": {
        "operationId": "list_support_tickets",
        "tags": [
          "Support"
        ],
        "summary": "Support tickets",
        "description": "The sub-account's Support tickets, newest activity first: subject, category, status (open, answered, resolved), who is answering (the assistant or the team), unread state and rating. The agency team sees every ticket; a client admin every ticket of the sub-account; anyone else their own. 403 feature_off while Support is off for the sub-account.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter.",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "answered",
                "resolved"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/support/tickets/{ticket_id}": {
      "get": {
        "operationId": "get_support_ticket",
        "tags": [
          "Support"
        ],
        "summary": "One support ticket and its messages",
        "description": "Every message in order (the customer, the assistant, the team), with the files' names. Internal notes only for the agency team.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "ticket_id",
            "in": "path",
            "required": true,
            "description": "Ticket id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/activity": {
      "get": {
        "operationId": "list_activity",
        "tags": [
          "Dashboard"
        ],
        "summary": "The Activity log",
        "description": "Everything that happened in the sub-account, newest first, as Settings > Activity log shows it: every change (the fields that changed, before and after, secrets hidden) with who made it (a person, an API key, the AI or an automation), their IP and browser, who opened what (contacts, conversations, recordings, exports), and messages, calls, bookings, automation runs, notifications and errors. Keyset paged by next_cursor. summary=true adds the page's counts by type and by day and who did the most. Owners and admins only.\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "1-365, default 30.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "ISO start, instead of days.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "ISO end, default now.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Comma-separated: change, access, lead, inbound, outbound, ai, call, booking, appointment, automation, notification, webhook, api, error, system.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "actor",
            "in": "query",
            "required": false,
            "description": "A user id, or user, api, ai, automation, lead or system.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "Only what happened to this lead.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "description": "Words in the title or description, or a contact's name, phone or email.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "summary",
            "in": "query",
            "required": false,
            "description": "Also return counts by type and day and the most active people.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "tz",
            "in": "query",
            "required": false,
            "description": "IANA time zone for summary days, default UTC.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-200, default 50.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "workspace_id": "uuid",
                    "window": {
                      "from": "2026-09-24T00:00:00Z",
                      "to": "2026-10-24T00:00:00Z",
                      "days": 30
                    },
                    "activity": [
                      {
                        "id": "al:uuid",
                        "occurred_at": "2026-10-24T15:02:11Z",
                        "source": "al",
                        "category": "change",
                        "title": null,
                        "description": "Changed the AI texting settings",
                        "status": "ok",
                        "lead_id": null,
                        "lead_name": null,
                        "lead_phone": null,
                        "actor_id": "uuid",
                        "actor_kind": "api",
                        "actor_label": "API key · Zapier",
                        "actor_name": "Pat Owner",
                        "actor_email": "pat@example.com",
                        "metadata": null,
                        "audit": {
                          "entity_table": "workspace_outreach_settings",
                          "action": "update",
                          "changed_fields": [
                            "ai_reply_enabled"
                          ],
                          "old_values": {
                            "ai_reply_enabled": false
                          },
                          "new_values": {
                            "ai_reply_enabled": true
                          },
                          "ip_address": "203.0.113.4",
                          "user_agent": "Zapier",
                          "source": "api"
                        }
                      }
                    ],
                    "has_more": true,
                    "next_cursor": "MjAyNi0xMC0yNFQxNTowMjoxMVp8YWw6dXVpZA"
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/review-funnels": {
      "get": {
        "operationId": "list_review_funnels",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Review pages",
        "description": "Tools → Review funnel: each review page, which one is the default, its rating threshold, where happy customers are sent, and its public_path (/r/<code> on the sub-account's domain).\n\nRequired scope: `workspaces:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/review-requests": {
      "get": {
        "operationId": "list_review_requests",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "Who was asked for a review, and what they did",
        "description": "Sent, opened, rated (1-5), clicked through to a review site, and any private feedback, most recently active first.\n\nRequired scope: `leads:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "workspace_id",
            "in": "query",
            "required": true,
            "description": "Sub-account id (omit on keys restricted to one sub-account).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "funnel_id",
            "in": "query",
            "required": false,
            "description": "One review page.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "query",
            "required": false,
            "description": "One lead.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rated",
            "in": "query",
            "required": false,
            "description": "Only rated (true) or not yet rated (false).",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "ISO time, changed at or after.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "1-100, default 25.",
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "description": "next_cursor from the previous page.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/review-link": {
      "post": {
        "operationId": "create_review_link",
        "tags": [
          "Invoices & reviews"
        ],
        "summary": "A lead's personal review link",
        "description": "Makes (or returns) the lead's link on a review page, like Copy review link on the lead. Sends nothing; share it however you like. Owners and admins only.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "funnel_id": {
                    "type": "string",
                    "description": "Which review page. Default: the default page."
                  }
                },
                "additionalProperties": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead_id": "uuid",
                    "code": "k3x9p2",
                    "url": "https://app.example-agency.com/r/k3x9p2"
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/notes/{note_id}": {
      "patch": {
        "operationId": "update_note",
        "tags": [
          "CRM leads"
        ],
        "summary": "Edit a note you wrote",
        "description": "Note ids are the note events in GET /v1/leads/{lead_id}/timeline. People can edit only their own notes, as in the app.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "required": true,
            "description": "Note id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "body": {
                    "type": "string",
                    "description": "The note, max 4000."
                  }
                },
                "required": [
                  "body"
                ],
                "additionalProperties": true
              },
              "example": {
                "body": "Prefers a call after 5pm."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      },
      "delete": {
        "operationId": "delete_note",
        "tags": [
          "CRM leads"
        ],
        "summary": "Delete a note",
        "description": "Owners and admins.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "note_id",
            "in": "path",
            "required": true,
            "description": "Note id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/leads/{lead_id}/do-not-contact": {
      "post": {
        "operationId": "set_do_not_contact",
        "tags": [
          "CRM leads"
        ],
        "summary": "Mark a lead do-not-contact",
        "description": "Like Do not contact on the Leads page: no more emails, and texts to the lead's number are blocked. The app has no undo, so it takes an owner or admin.\n\nRequired scope: `leads:write`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Unique string per logical operation. Replays within 24h return the original response instead of creating a duplicate or double-charging.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "lead_id",
            "in": "path",
            "required": true,
            "description": "Lead id.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "lead_id": "uuid",
                    "do_not_contact": true,
                    "emails_blocked": true,
                    "texts_blocked": true
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/v1/keys/self": {
      "get": {
        "operationId": "key_self",
        "tags": [
          "Account"
        ],
        "summary": "Inspect the calling API key",
        "description": "What this key may do and how much of it is used: `access_level` (read / write / admin / custom) and `scopes`, the `workspace` it is locked to (if any), `rate_limit_per_min`, `credit_budget` (limit, used, remaining and reset date; null when the key has no budget) and `usage_30d` (requests, errors, rate_limited). `type` is `account` (made in Settings → API) or `sub_account` (made in a sub-account's own Settings → API in the client CRM), and `endpoints` gives the API and MCP addresses for the host you called. A sub-account key can call this.\n\nRequired scope: `keys:read`.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests allowed per window for this key."
              },
              "X-RateLimit-Remaining": {
                "schema": {
                  "type": "integer"
                },
                "description": "Requests left in the current window."
              },
              "X-RateLimit-Reset": {
                "schema": {
                  "type": "integer"
                },
                "description": "Unix seconds when the window resets."
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessEnvelope"
                },
                "example": {
                  "success": true,
                  "data": {
                    "key": {
                      "id": "uuid",
                      "key_prefix": "zu-ab12",
                      "name": "Zapier",
                      "is_active": true,
                      "access_level": "write",
                      "scopes": [
                        "write"
                      ],
                      "workspace": {
                        "id": "uuid",
                        "name": "Acme Roofing"
                      },
                      "rate_limit_per_min": 120,
                      "credit_budget": {
                        "limit_per_month": 500,
                        "used_this_month": 88,
                        "remaining": 412,
                        "resets_at": "2026-10-01T00:00:00Z"
                      },
                      "usage_30d": {
                        "requests": 1830,
                        "errors": 12,
                        "rate_limited": 0
                      },
                      "last_used_at": "2026-09-30T15:00:00Z",
                      "created_at": "2026-09-01T00:00:00Z",
                      "type": "account"
                    },
                    "endpoints": {
                      "api": "https://api.ottopros.com/v1",
                      "mcp": "https://api.ottopros.com/mcp"
                    }
                  },
                  "error": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "An API key, e.g. `zu-...`. An admin creates one in Settings → API."
      }
    },
    "schemas": {
      "SuccessEnvelope": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "success"
        ]
      },
      "ConfirmationRequired": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "string"
          },
          "confirmation_required": {
            "type": "boolean",
            "const": true
          },
          "confirmation_token": {
            "type": "string",
            "description": "Single-use, expires after 10 minutes."
          },
          "estimated_credits": {
            "type": "number"
          }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "const": false
          },
          "data": {
            "type": "null"
          },
          "error": {
            "type": "string"
          },
          "details": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "success",
          "error"
        ]
      }
    },
    "responses": {
      "RateLimited": {
        "description": "Rate limit exceeded",
        "headers": {
          "X-RateLimit-Limit": {
            "schema": {
              "type": "integer"
            },
            "description": "Requests allowed per window for this key."
          },
          "X-RateLimit-Remaining": {
            "schema": {
              "type": "integer"
            },
            "description": "Requests left in the current window."
          },
          "X-RateLimit-Reset": {
            "schema": {
              "type": "integer"
            },
            "description": "Unix seconds when the window resets."
          },
          "Retry-After": {
            "schema": {
              "type": "integer"
            },
            "description": "Seconds to wait before retrying."
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      },
      "ConfirmationRequired": {
        "description": "Confirmation required, or not enough credits. Re-send the identical request with the returned confirmation_token to proceed.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ConfirmationRequired"
            }
          }
        }
      },
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            }
          }
        }
      }
    }
  }
}